Skip to content

Commit ed21303

Browse files
authored
Merge pull request #74482 from ahoppen/6.0/dynamic-cursor-info-on-decl
[SourceKit] Mark overridable declarations as dynamic
2 parents ddad629 + c7aa3ce commit ed21303

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/IDE/IDERequests.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ bool CursorInfoResolver::tryResolve(ValueDecl *D, TypeDecl *CtorTyRef,
158158
IsDynamic = true;
159159
ide::getReceiverType(BaseE, ReceiverTypes);
160160
}
161+
} else if (ExprStack.empty() && isDeclOverridable(D)) {
162+
// We aren't in a call (otherwise we would have an expression stack wouldn't
163+
// be empty), so we're at the declaration of an overridable declaration.
164+
// Mark the declaration as dynamic so that jump-to-definition can offer to
165+
// jump to any declaration that overrides this declaration.
166+
IsDynamic = true;
167+
ReceiverTypes.push_back(D->getDeclContext()->getSelfNominalTypeDecl());
161168
}
162169

163170
if (Data)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
protocol MyProto {
2+
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s
3+
func foo()
4+
}
5+
6+
// CHECK: DYNAMIC
7+
// CHECK: RECEIVERS BEGIN
8+
// CHECK: s:41cursor_of_protocol_requirement_is_dynamic7MyProtoP
9+
// CHECK: RECEIVERS END
10+
11+
class ClassA: MyProto {
12+
func foo() {}
13+
}
14+
15+
class ClassB: MyProto {
16+
func foo() {}
17+
}

0 commit comments

Comments
 (0)