Skip to content

Commit e71d921

Browse files
committed
[CS] Re-introduce some assertions
These FIXMEs appear to now be outdated. This commit also adds an additional assertion in `bindTypeVariable`.
1 parent c74a751 commit e71d921

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,10 +2394,7 @@ ConstraintSystem::matchTypesBindTypeVar(
23942394
TypeMatchOptions flags, ConstraintLocatorBuilder locator,
23952395
llvm::function_ref<TypeMatchResult()> formUnsolvedResult) {
23962396
assert(typeVar->is<TypeVariableType>() && "Expected a type variable!");
2397-
// FIXME: Due to some SE-0110 related code farther up we can end
2398-
// up with type variables wrapped in parens that will trip this
2399-
// assert. For now, maintain the existing behavior.
2400-
// assert(!type->is<TypeVariableType>() && "Expected a non-type variable!");
2397+
assert(!type->is<TypeVariableType>() && "Expected a non-type variable!");
24012398

24022399
// Simplify the right-hand type and perform the "occurs" check.
24032400
typeVar = getRepresentative(typeVar);
@@ -4104,14 +4101,8 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
41044101
return getTypeMatchSuccess();
41054102
}
41064103

4107-
assert((type1->is<TypeVariableType>() || type2->is<TypeVariableType>()) &&
4108-
"Expected a type variable!");
4109-
// FIXME: Due to some SE-0110 related code farther up we can end
4110-
// up with type variables wrapped in parens that will trip this
4111-
// assert. For now, maintain the existing behavior.
4112-
// assert(
4113-
// (!type1->is<TypeVariableType>() || !type2->is<TypeVariableType>())
4114-
// && "Expected a non-type variable!");
4104+
assert((type1->is<TypeVariableType>() != type2->is<TypeVariableType>()) &&
4105+
"Expected a type variable and a non type variable!");
41154106

41164107
auto *typeVar = typeVar1 ? typeVar1 : typeVar2;
41174108
auto type = typeVar1 ? type2 : type1;

lib/Sema/ConstraintGraph.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ void ConstraintGraph::mergeNodes(TypeVariableType *typeVar1,
428428
}
429429

430430
void ConstraintGraph::bindTypeVariable(TypeVariableType *typeVar, Type fixed) {
431+
assert(!fixed->is<TypeVariableType>() &&
432+
"Cannot bind to type variable; merge equivalence classes instead");
433+
431434
// If there are no type variables in the fixed type, there's nothing to do.
432435
if (!fixed->hasTypeVariable())
433436
return;

0 commit comments

Comments
 (0)