@@ -568,35 +568,13 @@ TypeSubstituter::transformOpaqueTypeArchetypeType(OpaqueTypeArchetypeType *opaqu
568
568
if (!IFS.shouldSubstituteOpaqueArchetypes ())
569
569
return std::nullopt;
570
570
571
- // If we have a substitution for this type, use it.
572
- if (auto known = IFS.substType (opaque, level)) {
573
- if (known->getCanonicalType () == opaque->getCanonicalType ())
574
- return std::nullopt; // Recursively process the substitutions of the
575
- // opaque type archetype.
576
- return known;
577
- }
578
-
579
- if (opaque->isRoot ())
580
- return ErrorType::get (opaque);
581
-
582
- // For nested archetypes, we can substitute the parent.
583
- Type origParent = opaque->getParent ();
584
- assert (origParent && " Not a nested archetype" );
585
-
586
- // Substitute into the parent type.
587
- Type substParent = doIt (origParent, TypePosition::Invariant);
571
+ auto known = IFS.substType (opaque, level);
572
+ ASSERT (known && " Opaque type replacement shouldn't fail" );
588
573
589
- // If the parent didn't change, we won't change.
590
- if (substParent.getPointer () == origParent.getPointer ())
591
- return Type (opaque);
592
-
593
- // Get the associated type reference from a child archetype.
594
- AssociatedTypeDecl *assocType = opaque->getInterfaceType ()
595
- ->castTo <DependentMemberType>()->getAssocType ();
596
-
597
- return getMemberForBaseType (IFS, origParent, substParent,
598
- assocType, assocType->getName (),
599
- level);
574
+ if (known->getCanonicalType () == opaque->getCanonicalType ())
575
+ return std::nullopt; // Recursively process the substitutions of the
576
+ // opaque type archetype.
577
+ return known;
600
578
}
601
579
602
580
std::optional<Type>
0 commit comments