Skip to content

Commit 7732c6a

Browse files
committed
AST: Simplify TypeSubstituter::transformLocalArchetypeType()
1 parent 0bfbc53 commit 7732c6a

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -582,33 +582,14 @@ TypeSubstituter::transformLocalArchetypeType(LocalArchetypeType *local,
582582
if (!IFS.shouldSubstituteLocalArchetypes())
583583
return std::nullopt;
584584

585-
// If we have a substitution for this type, use it.
586-
if (auto known = IFS.substType(local, level))
587-
return known;
585+
auto known = IFS.substType(local, level);
588586

589587
// FIXME: Change remaining callers to always substitute all local
590588
// archetypes.
591-
if (local->isRoot())
589+
if (!known)
592590
return Type(local);
593591

594-
// For nested archetypes, we can substitute the parent.
595-
Type origParent = local->getParent();
596-
assert(origParent && "Not a nested archetype");
597-
598-
// Substitute into the parent type.
599-
Type substParent = doIt(origParent, TypePosition::Invariant);
600-
601-
// If the parent didn't change, we won't change.
602-
if (substParent.getPointer() == origParent.getPointer())
603-
return Type(local);
604-
605-
// Get the associated type reference from a child archetype.
606-
AssociatedTypeDecl *assocType = local->getInterfaceType()
607-
->castTo<DependentMemberType>()->getAssocType();
608-
609-
return getMemberForBaseType(IFS, origParent, substParent,
610-
assocType, assocType->getName(),
611-
level);
592+
return known;
612593
}
613594

614595
Type TypeSubstituter::transformGenericTypeParamType(GenericTypeParamType *param,

0 commit comments

Comments
 (0)