Skip to content

Commit 620db5f

Browse files
committed
AST: Narrower workaround for "concrete conformance under abstract conformance" bug
Instead of just falling back to module lookup any time conformance substitution fails, only do it in the case we know doesn't work. This should shake out some more bugs, hopefully without causing too much pain.
1 parent c89ebec commit 620db5f

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

lib/AST/ProtocolConformance.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@ ProtocolConformanceRef::subst(Type origType,
162162
return ProtocolConformanceRef(lookupResults.front());
163163
}
164164

165-
// FIXME: Rip this out once ConformanceAccessPaths are plumbed through
166-
auto *M = proto->getParentModule();
167-
return *M->lookupConformance(substType, proto, nullptr);
165+
llvm_unreachable("Invalid conformance substitution");
168166
}
169167

170168
Type

lib/AST/SubstitutionMap.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,21 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
142142
// If we've hit an abstract conformance, everything from here on out is
143143
// abstract.
144144
// FIXME: This may not always be true, but it holds for now.
145-
if (conformance->isAbstract())
145+
if (conformance->isAbstract()) {
146+
// FIXME: Rip this out once we can get a concrete conformance from
147+
// an archetype.
148+
auto *M = proto->getParentModule();
149+
auto substType = type.subst(*this);
150+
if (substType &&
151+
!substType->is<ArchetypeType>() &&
152+
!substType->isTypeParameter() &&
153+
!substType->isExistentialType()) {
154+
auto lazyResolver = M->getASTContext().getLazyResolver();
155+
return *M->lookupConformance(substType, proto, lazyResolver);
156+
}
157+
146158
return ProtocolConformanceRef(proto);
159+
}
147160

148161
// For the second step, we're looking into the requirement signature for
149162
// this protocol.

lib/AST/Type.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,17 +2946,7 @@ Optional<ProtocolConformanceRef>
29462946
LookUpConformanceInSubstitutionMap::operator()(CanType dependentType,
29472947
Type conformingReplacementType,
29482948
ProtocolType *conformedProtocol) const {
2949-
auto result = Subs.lookupConformance(dependentType, conformedProtocol->getDecl());
2950-
if ((result && result->isConcrete()) ||
2951-
conformingReplacementType->hasError() ||
2952-
conformingReplacementType->isTypeParameter())
2953-
return result;
2954-
2955-
// FIXME: Rip this out once ConformanceAccessPaths are plumbed through
2956-
auto *M = conformedProtocol->getDecl()->getParentModule();
2957-
return M->lookupConformance(conformingReplacementType,
2958-
conformedProtocol->getDecl(),
2959-
nullptr);
2949+
return Subs.lookupConformance(dependentType, conformedProtocol->getDecl());
29602950
}
29612951

29622952
Optional<ProtocolConformanceRef>

0 commit comments

Comments
 (0)