Skip to content

Commit c3c25a1

Browse files
committed
AST: Small cleanup in ReplaceOpaqueTypesWithUnderlyingTypes
1 parent ee9f1dc commit c3c25a1

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,21 +1123,21 @@ operator()(CanType maybeOpaqueType, Type replacementType,
11231123
ProtocolDecl *protocol) const {
11241124
auto archetype = dyn_cast<OpaqueTypeArchetypeType>(maybeOpaqueType);
11251125
if (!archetype)
1126-
return lookupConformance(replacementType, protocol);
1126+
return ProtocolConformanceRef::forAbstract(maybeOpaqueType, protocol);
11271127

11281128
auto *genericEnv = archetype->getGenericEnvironment();
11291129
auto *decl = genericEnv->getOpaqueTypeDecl();
11301130
auto outerSubs = genericEnv->getOuterSubstitutions();
11311131

11321132
auto substitutionKind = shouldPerformSubstitution(decl);
11331133
if (substitutionKind == OpaqueSubstitutionKind::DontSubstitute)
1134-
return lookupConformance(replacementType, protocol);
1134+
return ProtocolConformanceRef::forAbstract(replacementType, protocol);
11351135

11361136
auto subs = decl->getUniqueUnderlyingTypeSubstitutions();
11371137
// If the body of the opaque decl providing decl has not been type checked we
11381138
// don't have a underlying substitution.
11391139
if (!subs.has_value())
1140-
return lookupConformance(replacementType, protocol);
1140+
return ProtocolConformanceRef::forAbstract(replacementType, protocol);
11411141

11421142
// Apply the underlying type substitutions to the interface type of the
11431143
// archetype in question. This will map the inner generic signature of the
@@ -1158,21 +1158,15 @@ operator()(CanType maybeOpaqueType, Type replacementType,
11581158
return true;
11591159
return false;
11601160
}))
1161-
return lookupConformance(replacementType, protocol);
1162-
1163-
// Then apply the substitutions from the root opaque archetype, to specialize
1164-
// for its type arguments. We perform this substitution after checking for
1165-
// visibility, since we do not want the result of the visibility check to
1166-
// depend on the substitutions previously applied.
1167-
auto substTy = partialSubstTy.subst(outerSubs);
1161+
return ProtocolConformanceRef::forAbstract(replacementType, protocol);
11681162

11691163
auto partialSubstRef =
11701164
subs->lookupConformance(archetype->getInterfaceType()->getCanonicalType(),
11711165
protocol);
11721166
auto substRef = partialSubstRef.subst(outerSubs);
11731167

11741168
// If the type still contains opaque types, recur.
1175-
if (substTy->hasOpaqueArchetype()) {
1169+
if (substRef.getType()->hasOpaqueArchetype()) {
11761170
SeenDecl seenKey(decl, outerSubs);
11771171

11781172
if (auto *alreadySeen = this->seenDecls) {

0 commit comments

Comments
 (0)