@@ -52,11 +52,15 @@ static bool hasRecursiveCallInPath(SILBasicBlock &Block,
5252
5353 if (FullApplySite FAI = FullApplySite::isa (&I)) {
5454 // Don't touch dynamic dispatch.
55- if (isa<ObjCMethodInst>(FAI.getCallee ()))
55+ const auto callee = FAI.getCallee ();
56+ if (isa<SuperMethodInst>(callee) ||
57+ isa<ObjCSuperMethodInst>(callee) ||
58+ isa<ObjCMethodInst>(callee)) {
5659 continue ;
60+ }
5761
5862 auto &M = FAI.getModule ();
59- if (auto *CMI = dyn_cast<ClassMethodInst>(FAI. getCallee () )) {
63+ if (auto *CMI = dyn_cast<ClassMethodInst>(callee )) {
6064 auto ClassType = CMI->getOperand ()->getType ().getASTType ();
6165
6266 // FIXME: If we're not inside the module context of the method,
@@ -71,14 +75,26 @@ static bool hasRecursiveCallInPath(SILBasicBlock &Block,
7175 continue ;
7276 }
7377
78+ if (!calleesAreStaticallyKnowable (FAI.getModule (), CMI->getMember ())) {
79+ continue ;
80+ }
81+
82+ // The "statically knowable" check just means that we have all the
83+ // callee candidates available for analysis. We still need to check
84+ // if the current function has a known override point.
85+ auto *method = CMI->getMember ().getAbstractFunctionDecl ();
86+ if (method->isOverridden ()) {
87+ continue ;
88+ }
89+
7490 auto *F = getTargetClassMethod (M, CD, CMI);
7591 if (F == Target)
7692 return true ;
7793
7894 continue ;
7995 }
8096
81- if (auto *WMI = dyn_cast<WitnessMethodInst>(FAI. getCallee () )) {
97+ if (auto *WMI = dyn_cast<WitnessMethodInst>(callee )) {
8298 SILFunction *F;
8399 SILWitnessTable *WT;
84100
0 commit comments