Skip to content

Commit e679dab

Browse files
authored
Merge pull request #59676 from slavapestov/subst-map-superclass-check
AST: Remove unnecessary superclass bound check in SubstitutionMap::lookupConformance()
2 parents 2037006 + 665faf5 commit e679dab

File tree

3 files changed

+10
-32
lines changed

3 files changed

+10
-32
lines changed

lib/AST/SubstitutionMap.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,6 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
359359
if (auto directConformance = getSignatureConformance(type, proto))
360360
return *directConformance;
361361

362-
// Check whether the superclass conforms.
363-
if (auto superclass = genericSig->getSuperclassBound(type)) {
364-
LookUpConformanceInSignature lookup(getGenericSignature().getPointer());
365-
auto substType = type.subst(*this);
366-
if (auto conformance = lookup(type->getCanonicalType(), substType, proto)){
367-
return conformance;
368-
}
369-
}
370-
371362
// If the type doesn't conform to this protocol, the result isn't formed
372363
// from these requirements.
373364
if (!genericSig->requiresProtocol(type, proto)) {
@@ -378,7 +369,6 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
378369
auto accessPath =
379370
genericSig->getConformanceAccessPath(type, proto);
380371

381-
// Fall through because we cannot yet evaluate an access path.
382372
ProtocolConformanceRef conformance;
383373
for (const auto &step : accessPath) {
384374
// For the first step, grab the initial conformance.

lib/SILOptimizer/Differentiation/JVPCloner.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -702,22 +702,16 @@ class JVPCloner::Implementation final
702702
extractAllElements(origResult, builder, origResults);
703703

704704
// Get and partially apply the differential.
705-
auto jvpGenericEnv = jvp->getGenericEnvironment();
706-
auto jvpSubstMap = jvpGenericEnv
707-
? jvpGenericEnv->getForwardingSubstitutionMap()
708-
: jvp->getForwardingSubstitutionMap();
705+
auto jvpSubstMap = jvp->getForwardingSubstitutionMap();
709706
auto *differentialRef = builder.createFunctionRef(loc, &getDifferential());
710707
auto *differentialPartialApply = builder.createPartialApply(
711708
loc, differentialRef, jvpSubstMap, {diffStructVal},
712709
ParameterConvention::Direct_Guaranteed);
713710

714-
auto differentialType = jvp->getLoweredFunctionType()
715-
->getResults()
716-
.back()
717-
.getSILStorageInterfaceType();
718-
differentialType = differentialType.substGenericArgs(
719-
getModule(), jvpSubstMap, TypeExpansionContext::minimal());
720-
differentialType = differentialType.subst(getModule(), jvpSubstMap);
711+
auto differentialType = jvp->mapTypeIntoContext(
712+
jvp->getConventions().getSILType(
713+
jvp->getLoweredFunctionType()->getResults().back(),
714+
jvp->getTypeExpansionContext()));
721715
auto differentialFnType = differentialType.castTo<SILFunctionType>();
722716
auto differentialSubstType =
723717
differentialPartialApply->getType().castTo<SILFunctionType>();

lib/SILOptimizer/Differentiation/VJPCloner.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ class VJPCloner::Implementation final
231231
extractAllElements(origResult, Builder, origResults);
232232

233233
// Get and partially apply the pullback.
234-
auto vjpGenericEnv = vjp->getGenericEnvironment();
235-
auto vjpSubstMap = vjpGenericEnv
236-
? vjpGenericEnv->getForwardingSubstitutionMap()
237-
: vjp->getForwardingSubstitutionMap();
234+
auto vjpSubstMap = vjp->getForwardingSubstitutionMap();
238235
auto *pullbackRef = Builder.createFunctionRef(loc, pullback);
239236

240237
// Prepare partial application arguments.
@@ -257,13 +254,10 @@ class VJPCloner::Implementation final
257254
auto *pullbackPartialApply = Builder.createPartialApply(
258255
loc, pullbackRef, vjpSubstMap, {partialApplyArg},
259256
ParameterConvention::Direct_Guaranteed);
260-
auto pullbackType = vjp->getLoweredFunctionType()
261-
->getResults()
262-
.back()
263-
.getSILStorageInterfaceType();
264-
pullbackType = pullbackType.substGenericArgs(
265-
getModule(), vjpSubstMap, TypeExpansionContext::minimal());
266-
pullbackType = pullbackType.subst(getModule(), vjpSubstMap);
257+
auto pullbackType = vjp->mapTypeIntoContext(
258+
vjp->getConventions().getSILType(
259+
vjp->getLoweredFunctionType()->getResults().back(),
260+
vjp->getTypeExpansionContext()));
267261
auto pullbackFnType = pullbackType.castTo<SILFunctionType>();
268262
auto pullbackSubstType =
269263
pullbackPartialApply->getType().castTo<SILFunctionType>();

0 commit comments

Comments
 (0)