Skip to content

Commit 0b961c6

Browse files
committed
AST: Clean up InFlightSubstitution::lookupConformance()
The special handling of DynamicSelfType should no longer be necessary so I'm removing it.
1 parent ba0ec53 commit 0b961c6

File tree

4 files changed

+18
-27
lines changed

4 files changed

+18
-27
lines changed

include/swift/AST/InFlightSubstitution.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class InFlightSubstitution {
5252
Type substType(SubstitutableType *origType, unsigned level);
5353

5454
/// Perform primitive conformance lookup on the given type.
55-
ProtocolConformanceRef lookupConformance(CanType dependentType,
56-
Type conformingReplacementType,
55+
ProtocolConformanceRef lookupConformance(Type dependentType,
5756
ProtocolDecl *conformedProtocol,
5857
unsigned level);
5958

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ ProtocolConformanceRef::subst(InFlightSubstitution &IFS) const {
111111

112112
// Local conformance lookup into the substitution map.
113113
// FIXME: Pack element level?
114-
return IFS.lookupConformance(origType->getCanonicalType(),
115-
origType.subst(IFS), proto,
116-
/*level=*/0);
114+
return IFS.lookupConformance(origType, proto, /*level=*/0);
117115
}
118116

119117
ProtocolConformanceRef ProtocolConformanceRef::mapConformanceOutOfContext() const {

lib/AST/SubstitutionMap.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,12 @@ SubstitutionMap SubstitutionMap::get(GenericSignature genericSig,
174174
// Form the stored conformances.
175175
SmallVector<ProtocolConformanceRef, 4> conformances;
176176
for (const auto &req : genericSig.getRequirements()) {
177-
if (req.getKind() != RequirementKind::Conformance) continue;
178-
179-
Type depTy = req.getFirstType();
180-
auto replacement = depTy.subst(IFS);
181-
auto *proto = req.getProtocolDecl();
182-
auto conformance = IFS.lookupConformance(
183-
depTy->getCanonicalType(), replacement, proto, /*level=*/0);
184-
conformances.push_back(conformance);
177+
if (req.getKind() != RequirementKind::Conformance)
178+
continue;
179+
180+
conformances.push_back(
181+
IFS.lookupConformance(
182+
req.getFirstType(), req.getProtocolDecl(), /*level=*/0));
185183
}
186184

187185
return SubstitutionMap(genericSig, types, conformances);

lib/AST/TypeSubstitution.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@ Type InFlightSubstitution::substType(SubstitutableType *origType,
273273
}
274274

275275
ProtocolConformanceRef
276-
InFlightSubstitution::lookupConformance(CanType dependentType,
277-
Type conformingReplacementType,
276+
InFlightSubstitution::lookupConformance(Type dependentType,
278277
ProtocolDecl *conformedProtocol,
279278
unsigned level) {
280-
auto substConfRef = BaselineLookupConformance(dependentType,
281-
conformingReplacementType,
282-
conformedProtocol);
279+
auto substConfRef = BaselineLookupConformance(
280+
dependentType->getCanonicalType(),
281+
dependentType.subst(*this),
282+
conformedProtocol);
283283
if (!substConfRef ||
284284
ActivePackExpansions.empty() ||
285285
!substConfRef.isPack())
@@ -430,22 +430,18 @@ Type TypeSubstituter::transformPackElementType(PackElementType *element,
430430
Type TypeSubstituter::transformDependentMemberType(DependentMemberType *dependent,
431431
TypePosition pos) {
432432
auto origBase = dependent->getBase();
433-
auto substBase = doIt(origBase, TypePosition::Invariant);
434-
435-
if (auto *selfType = substBase->getAs<DynamicSelfType>())
436-
substBase = selfType->getSelfType();
437433

438434
auto *assocType = dependent->getAssocType();
439435
ASSERT(assocType);
440436

441-
auto proto = assocType->getProtocol();
442-
ProtocolConformanceRef conformance =
443-
IFS.lookupConformance(origBase->getCanonicalType(), substBase,
444-
proto, level);
437+
auto *proto = assocType->getProtocol();
438+
auto conformance = IFS.lookupConformance(origBase, proto, level);
445439

446440
auto result = conformance.getTypeWitness(assocType, IFS.getOptions());
447-
if (result->is<ErrorType>())
441+
if (result->is<ErrorType>()) {
442+
auto substBase = origBase.subst(IFS);
448443
return DependentMemberType::get(ErrorType::get(substBase), assocType);
444+
}
449445
return result;
450446
}
451447

0 commit comments

Comments
 (0)