@@ -3663,12 +3663,10 @@ static SILFunction *getOrCreateKeyPathSetter(
36633663 return thunk;
36643664}
36653665
3666- static SILFunction *getOrCreateKeyPathAppliedMethod (
3667- SILGenModule &SGM, AbstractFunctionDecl *method, SubstitutionMap subs,
3668- GenericEnvironment *genericEnv, ResilienceExpansion expansion,
3669- ArrayRef<IndexTypePair> args, CanType baseType, CanType methodType) {
3670-
3671- // Handle protocol method overrides for key paths
3666+ // / For keypaths to methods defined in protocols, use the decl defined in the
3667+ // / conforming type's implementation.
3668+ static void lookupMethodViaProtocol (AbstractFunctionDecl *&method,
3669+ SubstitutionMap &subs) {
36723670 if (isa<ProtocolDecl>(method->getDeclContext ())) {
36733671 if (!method->requiresNewWitnessTableEntry ()) {
36743672 // Find the method that has a witness table entry
@@ -3681,6 +3679,13 @@ static SILFunction *getOrCreateKeyPathAppliedMethod(
36813679 method = wtableMethod;
36823680 }
36833681 }
3682+ }
3683+
3684+ static SILFunction *getOrCreateKeyPathAppliedMethod (
3685+ SILGenModule &SGM, AbstractFunctionDecl *method, SubstitutionMap subs,
3686+ GenericEnvironment *genericEnv, ResilienceExpansion expansion,
3687+ ArrayRef<IndexTypePair> args, CanType baseType, CanType methodType) {
3688+ lookupMethodViaProtocol (method, subs);
36843689
36853690 auto genericSig =
36863691 genericEnv ? genericEnv->getGenericSignature ().getCanonicalSignature ()
0 commit comments