mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add a DeclContext Parameter to Opened Archetype Construction
This ensures that opened archetypes always inherit any outer generic parameters from the context in which they reside. This matters because class bounds may bind generic parameters from these outer contexts, and without the outer context you can wind up with ill-formed generic environments like <τ_0_0, where τ_0_0 : C<T>, τ_0_0 : P> Where T is otherwise unbound because there is no entry for it among the generic parameters of the environment's associated generic signature.
This commit is contained in:
@@ -10120,7 +10120,8 @@ ConstraintSystem::simplifyOpenedExistentialOfConstraint(
|
||||
instanceTy = metaTy->getExistentialInstanceType();
|
||||
}
|
||||
assert(instanceTy->isExistentialType());
|
||||
Type openedTy = OpenedArchetypeType::get(instanceTy->getCanonicalType());
|
||||
Type openedTy =
|
||||
OpenedArchetypeType::get(instanceTy->getCanonicalType(), DC);
|
||||
if (isMetatype)
|
||||
openedTy = MetatypeType::get(openedTy, getASTContext());
|
||||
return matchTypes(type1, openedTy, ConstraintKind::Bind, subflags, locator);
|
||||
@@ -11119,7 +11120,7 @@ ConstraintSystem::simplifyApplicableFnConstraint(
|
||||
if (result2->hasTypeVariable() && !openedExistentials.empty()) {
|
||||
for (const auto &opened : openedExistentials) {
|
||||
result2 = typeEraseOpenedExistentialReference(
|
||||
result2, opened.second->getExistentialType(), opened.first);
|
||||
result2, opened.second->getExistentialType(), opened.first, DC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user