Skip to content

Commit 1218613

Browse files
author
Nathan Hawes
committed
[IDE] Fix CursorInfo crash on arg label when the called 'function' is actually a module decl.
1 parent 4293772 commit 1218613

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/IDE/IDERequests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ bool CursorInfoResolver::visitCallArgName(Identifier Name,
267267
ValueDecl *D) {
268268
if (isDone())
269269
return false;
270+
271+
// Handle invalid code where the called decl isn't actually callable, so this
272+
// argument label doesn't really refer to it.
273+
if (isa<ModuleDecl>(D))
274+
return true;
275+
270276
bool Found = tryResolve(D, nullptr, nullptr, Range.getStart(), /*IsRef=*/true);
271277
if (Found)
272278
CursorInfo.IsKeywordArgument = true;

test/SourceKit/CursorInfo/cursor_invalid.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func ==(x: C, y: C)
2222

2323
func resyncParser2() {}
2424

25+
Swift(label: 3)
26+
2527
// RUN: %sourcekitd-test -req=cursor -pos=4:13 %s -- %s | %FileCheck -check-prefix=CHECK1 %s
2628
// CHECK1: source.lang.swift.decl.var.local (4:13-4:14)
2729
// CHECK1: c
@@ -59,3 +61,5 @@ func resyncParser2() {}
5961

6062
// RUN: %sourcekitd-test -req=cursor -pos=21:6 %s -- %s | %FileCheck -check-prefix=EQEQ3 %s
6163
// EQEQ3: <decl.function.operator.infix><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>== </decl.name>(<decl.var.parameter><decl.var.parameter.name>x</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>, <decl.var.parameter><decl.var.parameter.name>y</decl.var.parameter.name>: <decl.var.parameter.type><ref.class usr="s:14cursor_invalid1CC">C</ref.class></decl.var.parameter.type></decl.var.parameter>)</decl.function.operator.infix>
64+
65+
// RUN: %sourcekitd-test -req=cursor -pos=25:7 %s -- %s | %FileCheck -check-prefix=DIAG %s

0 commit comments

Comments
 (0)