@@ -93,23 +93,24 @@ ProtocolConformanceRef::subst(Type origType, InFlightSubstitution &IFS) const {
9393 if (isPack ())
9494 return getPack ()->subst (IFS);
9595
96- // Handle abstract conformances below:
96+ ASSERT (isAbstract ());
97+ auto *proto = getProtocol ();
9798
9899 // If the type is an opaque archetype, the conformance will remain abstract,
99100 // unless we're specifically substituting opaque types.
100- if (auto origArchetype = origType->getAs <ArchetypeType>()) {
101- if (!IFS.shouldSubstituteOpaqueArchetypes ()
102- && isa<OpaqueTypeArchetypeType>(origArchetype)) {
103- return *this ;
101+ if (auto origArchetype = origType->getAs <OpaqueTypeArchetypeType>()) {
102+ if (!IFS.shouldSubstituteOpaqueArchetypes ()) {
103+ return forAbstract (origType.subst (IFS), proto);
104104 }
105105 }
106106
107+ // FIXME: Handle local archetypes as above!
108+
107109 // Otherwise, compute the substituted type.
108110 auto substType = origType.subst (IFS);
109111
110- auto *proto = getProtocol ();
111-
112112 // If the type is an existential, it must be self-conforming.
113+ // FIXME: This feels like it's in the wrong place.
113114 if (substType->isExistentialType ()) {
114115 auto optConformance =
115116 lookupConformance (substType, proto, /* allowMissing=*/ true );
@@ -119,7 +120,7 @@ ProtocolConformanceRef::subst(Type origType, InFlightSubstitution &IFS) const {
119120 return ProtocolConformanceRef::forInvalid ();
120121 }
121122
122- // Check the conformance map.
123+ // Local conformance lookup into the substitution map.
123124 // FIXME: Pack element level?
124125 return IFS.lookupConformance (origType->getCanonicalType (), substType, proto,
125126 /* level=*/ 0 );
0 commit comments