Skip to content

Commit cd77027

Browse files
committed
Sema: Banish GenericTypeParamType from the constraint system
1 parent 209e266 commit cd77027

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Sema/Constraint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Constraint::Constraint(ConstraintKind kind, ArrayRef<Constraint *> constraints,
4848
}
4949

5050
static bool isAdmissibleType(Type type) {
51-
return !type->hasUnboundGenericType();
51+
return !type->hasUnboundGenericType() && !type->hasTypeParameter();
5252
}
5353

5454
Constraint::Constraint(ConstraintKind Kind, Type First, Type Second,

lib/Sema/TypeOfReference.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ Type ConstraintSystem::openUnboundGenericType(GenericTypeDecl *decl,
7272
if (found == subs.end())
7373
continue;
7474

75+
// When a nominal type is declared in generic local context (which is
76+
// not actually valid anyway), the context substitution map will map
77+
// the outer generic parameters to themselves. Skip such entries to
78+
// avoid introducing constraints that contain type parameters into
79+
// the solver.
80+
if (found->second->hasTypeParameter())
81+
continue;
82+
7583
addConstraint(ConstraintKind::Bind, pair.second, found->second,
7684
locator);
7785
}

0 commit comments

Comments
 (0)