Skip to content

Commit 53f52c4

Browse files
committed
[CS] Split out element archetype handling in resolveType
Make sure we do this after we transform the type as otherwise we could skip resolving type variables and let them escape.
1 parent 55a38ba commit 53f52c4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ Type FailureDiagnostic::resolveType(Type rawType, bool reconstituteSugar,
122122
: resolvedType;
123123
}
124124

125-
if (type->hasElementArchetype()) {
126-
auto *env = getDC()->getGenericEnvironmentOfContext();
127-
return env->mapElementTypeIntoPackContext(type);
128-
}
129-
130125
if (type->isPlaceholder())
131126
return ErrorType::get(type->getASTContext());
132127

133128
return std::nullopt;
134129
});
135130

131+
if (rawType->hasElementArchetype()) {
132+
auto *env = getDC()->getGenericEnvironmentOfContext();
133+
rawType = env->mapElementTypeIntoPackContext(rawType);
134+
}
135+
136136
if (reconstituteSugar)
137137
rawType = rawType->reconstituteSugar(/*recursive*/ true);
138138
return wantRValue ? rawType->getRValueType() : rawType;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// {"kind":"typecheck","signature":"swift::TypeChecker::typesSatisfyConstraint(swift::Type, swift::Type, bool, swift::constraints::ConstraintKind, swift::DeclContext*, bool*)","signatureAssert":"Assertion failed: (!type1->getRecursiveProperties().isSolverAllocated() && !type2->getRecursiveProperties().isSolverAllocated() && \"Cannot escape solver-allocated types into a nested ConstraintSystem\"), function typesSatisfyConstraint"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
func a<each b>(c : repeat each b) { repeat !(d c

0 commit comments

Comments
 (0)