Skip to content

Commit 3eb6ac1

Browse files
committed
[CS] Assert that we don't end up with unsolved constraints
1 parent f88c955 commit 3eb6ac1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4296,6 +4296,13 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
42964296
llvm_unreachable("type variables should have already been handled by now");
42974297

42984298
case TypeKind::DependentMember: {
4299+
// If one of the dependent member types has no type variables,
4300+
// this comparison is effectively illformed, because dependent
4301+
// member couldn't be simplified down to the actual type, and
4302+
// we wouldn't be able to solve this constraint, so let's just fail.
4303+
if (!desugar1->hasTypeVariable() || !desugar2->hasTypeVariable())
4304+
return getTypeMatchFailure(locator);
4305+
42994306
// Nothing we can solve yet, since we need to wait until
43004307
// type variables will get resolved.
43014308
return formUnsolvedResult();

lib/Sema/CSStep.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ StepResult ComponentStep::take(bool prevFailed) {
354354
return finalize(/*isSuccess=*/false);
355355
}
356356

357+
assert(CS.ActiveConstraints.empty());
358+
assert((CS.InactiveConstraints.empty() && !CS.hasFreeTypeVariables()) ||
359+
CS.solverState->allowsFreeTypeVariables());
360+
357361
// If this solution is worse than the best solution we've seen so far,
358362
// skip it.
359363
if (CS.worseThanBestSolution())

0 commit comments

Comments
 (0)