mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Use new form of getOpenedExistentialSignature() in GenericEnvironment::forOpenedExistential()
This commit is contained in:
@@ -295,9 +295,9 @@ Type
|
||||
GenericEnvironment::maybeApplyOuterContextSubstitutions(Type type) const {
|
||||
switch (getKind()) {
|
||||
case Kind::Primary:
|
||||
case Kind::OpenedExistential:
|
||||
return type;
|
||||
|
||||
case Kind::OpenedExistential:
|
||||
case Kind::OpenedElement:
|
||||
case Kind::Opaque: {
|
||||
OuterSubstitutions replacer{
|
||||
@@ -358,25 +358,8 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
|
||||
auto genericSig = getGenericSignature();
|
||||
auto requirements = genericSig->getLocalRequirements(depType);
|
||||
|
||||
/// Substitute a type for the purpose of requirements.
|
||||
auto substForRequirements = [&](Type type) {
|
||||
switch (getKind()) {
|
||||
case Kind::Primary:
|
||||
case Kind::OpenedExistential:
|
||||
if (type->hasTypeParameter()) {
|
||||
return mapTypeIntoContext(type, LookUpConformanceInModule());
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
case Kind::OpenedElement:
|
||||
case Kind::Opaque:
|
||||
return maybeApplyOuterContextSubstitutions(type);
|
||||
}
|
||||
};
|
||||
|
||||
if (requirements.concreteType) {
|
||||
return substForRequirements(requirements.concreteType);
|
||||
}
|
||||
if (requirements.concreteType)
|
||||
return mapTypeIntoContext(requirements.concreteType);
|
||||
|
||||
assert(requirements.anchor && "No anchor or concrete type?");
|
||||
|
||||
@@ -404,7 +387,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
|
||||
// Substitute into the superclass.
|
||||
Type superclass = requirements.superclass;
|
||||
if (superclass && superclass->hasTypeParameter()) {
|
||||
superclass = substForRequirements(superclass);
|
||||
superclass = mapTypeIntoContext(superclass);
|
||||
if (superclass->is<ErrorType>())
|
||||
superclass = Type();
|
||||
}
|
||||
@@ -428,14 +411,10 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
|
||||
break;
|
||||
|
||||
case Kind::Opaque: {
|
||||
assert(!rootGP->isParameterPack());
|
||||
|
||||
// If the anchor type isn't rooted in a generic parameter that
|
||||
// represents an opaque declaration, then apply the outer substitutions.
|
||||
// It would be incorrect to build an opaque type archetype here.
|
||||
unsigned opaqueDepth =
|
||||
getOpaqueTypeDecl()->getOpaqueGenericParams().front()->getDepth();
|
||||
if (rootGP->getDepth() < opaqueDepth) {
|
||||
if (rootGP->getDepth() < genericSig->getMaxDepth()) {
|
||||
result = maybeApplyOuterContextSubstitutions(requirements.anchor);
|
||||
break;
|
||||
}
|
||||
@@ -447,7 +426,10 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
|
||||
}
|
||||
|
||||
case Kind::OpenedExistential: {
|
||||
assert(!rootGP->isParameterPack());
|
||||
if (rootGP->getDepth() < genericSig->getMaxDepth()) {
|
||||
result = maybeApplyOuterContextSubstitutions(requirements.anchor);
|
||||
break;
|
||||
}
|
||||
|
||||
// FIXME: The existential layout's protocols might differ from the
|
||||
// canonicalized set of protocols determined by the generic signature.
|
||||
@@ -475,10 +457,7 @@ GenericEnvironment::getOrCreateArchetypeFromInterfaceType(Type depType) {
|
||||
}
|
||||
|
||||
case Kind::OpenedElement: {
|
||||
auto packElements = getGenericSignature().getInnermostGenericParams();
|
||||
auto elementDepth = packElements.front()->getDepth();
|
||||
|
||||
if (rootGP->getDepth() < elementDepth) {
|
||||
if (rootGP->getDepth() < genericSig->getMaxDepth()) {
|
||||
result = maybeApplyOuterContextSubstitutions(requirements.anchor);
|
||||
break;
|
||||
}
|
||||
@@ -536,9 +515,7 @@ Type GenericEnvironment::mapTypeIntoContext(
|
||||
Type result = type.subst(QueryInterfaceTypeSubstitutions(this),
|
||||
lookupConformance,
|
||||
SubstFlags::PreservePackExpansionLevel);
|
||||
assert((!result->hasTypeParameter() || result->hasError() ||
|
||||
getKind() == Kind::Opaque) &&
|
||||
"not fully substituted");
|
||||
ASSERT(getKind() != Kind::Primary || !result->hasTypeParameter());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user