mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Give opened archetypes a generic environment.
And maybe allow nested types to live on them.
This commit is contained in:
@@ -2811,6 +2811,8 @@ static void concretizeNestedTypeFromConcreteParent(
|
||||
->getTypeWitness(assocType, builder.getLazyResolver());
|
||||
if (!witnessType || witnessType->hasError())
|
||||
return; // FIXME: should we delay here?
|
||||
} else if (auto archetype = concreteParent->getAs<ArchetypeType>()) {
|
||||
witnessType = archetype->getNestedType(assocType->getName());
|
||||
} else {
|
||||
witnessType = DependentMemberType::get(concreteParent, assocType);
|
||||
}
|
||||
@@ -2902,7 +2904,7 @@ PotentialArchetype *PotentialArchetype::updateNestedTypeForConformance(
|
||||
|
||||
void ArchetypeType::resolveNestedType(
|
||||
std::pair<Identifier, Type> &nested) const {
|
||||
auto genericEnv = getPrimary()->getGenericEnvironment();
|
||||
auto genericEnv = getGenericEnvironment();
|
||||
auto &builder = *genericEnv->getGenericSignatureBuilder();
|
||||
|
||||
Type interfaceType = getInterfaceType();
|
||||
@@ -3886,7 +3888,7 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
|
||||
}
|
||||
|
||||
// The equivalence class of a dependent member type is determined by its
|
||||
// base equivalence class.
|
||||
// base equivalence class, if there is one.
|
||||
if (auto depMemTy = type->getAs<DependentMemberType>()) {
|
||||
// Find the equivalence class of the base.
|
||||
auto resolvedBase =
|
||||
@@ -3894,6 +3896,9 @@ ResolvedType GenericSignatureBuilder::maybeResolveEquivalenceClass(
|
||||
resolutionKind,
|
||||
wantExactPotentialArchetype);
|
||||
if (!resolvedBase) return resolvedBase;
|
||||
// If the base is concrete, so is this member.
|
||||
if (resolvedBase.getAsConcreteType())
|
||||
return ResolvedType::forConcrete(type);
|
||||
|
||||
// Find the nested type declaration for this.
|
||||
auto baseEquivClass = resolvedBase.getEquivalenceClass(*this);
|
||||
|
||||
Reference in New Issue
Block a user