Remove NestedArchetypeType.

Nested archetypes are represented by their base archetype kinds (primary,
opened, or opaque type) with an interface type that is a nested type,
as represented by a DependentMemberType. This provides a more uniform
representation of archetypes throughout the frontend.
This commit is contained in:
Doug Gregor
2022-01-13 22:09:03 -08:00
parent 96fdbe18ea
commit 452eccab83
16 changed files with 5 additions and 205 deletions

View File

@@ -5884,33 +5884,6 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
break;
}
// Same for nested archetypes rooted in opaque types.
case TypeKind::NestedArchetype: {
auto nested1 = cast<NestedArchetypeType>(desugar1);
auto nested2 = cast<NestedArchetypeType>(desugar2);
auto rootOpaque1 = dyn_cast<OpaqueTypeArchetypeType>(nested1->getRoot());
auto rootOpaque2 = dyn_cast<OpaqueTypeArchetypeType>(nested2->getRoot());
if (rootOpaque1 && rootOpaque2) {
auto interfaceTy1 = rootOpaque1->getCanonicalInterfaceType(
nested1->getInterfaceType());
auto interfaceTy2 = rootOpaque2->getCanonicalInterfaceType(
nested2->getInterfaceType());
if (interfaceTy1->isEqual(interfaceTy2)
&& rootOpaque1->getDecl() == rootOpaque2->getDecl()) {
conversionsOrFixes.push_back(ConversionRestrictionKind::DeepEquality);
break;
}
}
// Before failing, let's give repair a chance to run in diagnostic mode.
if (shouldAttemptFixes())
break;
// If the archetypes aren't rooted in an opaque type, or are rooted in
// completely different decls, then there's nothing else we can do.
return getTypeMatchFailure(locator);
}
case TypeKind::Pack: {
auto tmpPackLoc = locator.withPathElement(LocatorPathElt::PackType(type1));
auto packLoc = tmpPackLoc.withPathElement(LocatorPathElt::PackType(type2));
@@ -6475,7 +6448,6 @@ ConstraintSystem::simplifyConstructionConstraint(
case TypeKind::BoundGenericStruct:
case TypeKind::PrimaryArchetype:
case TypeKind::OpenedArchetype:
case TypeKind::NestedArchetype:
case TypeKind::OpaqueTypeArchetype:
case TypeKind::SequenceArchetype:
case TypeKind::DynamicSelf: