Skip to content

Commit 7d8dba3

Browse files
authored
Merge pull request swiftlang#21528 from nathawes/r46694149-cursor-info-crash-in-extractInlinableText-5.0
[5.0][sourcekitd][AST] Fix CursorInfo crash on method with unresolved default value
2 parents de0187a + 9287082 commit 7d8dba3

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

lib/AST/Decl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5109,6 +5109,14 @@ ParamDecl::getDefaultValueStringRepresentation(
51095109
DefaultValueAndIsVariadic.getPointer()->StringRepresentation;
51105110
if (!existing.empty())
51115111
return existing;
5112+
5113+
if (!getDefaultValue()) {
5114+
// TypeChecker::checkDefaultArguments() nulls out the default value
5115+
// if it fails to type check it. This only seems to happen with an
5116+
// invalid/incomplete parameter list that contains a parameter with an
5117+
// unresolved default value.
5118+
return "<<empty>>";
5119+
}
51125120
return extractInlinableText(getASTContext().SourceMgr, getDefaultValue(),
51135121
scratch);
51145122
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
enum LogLevel { case error }
2+
3+
func logAsync(level: LogLevel = undefined, messageProducer producer
4+
5+
// RUN: %sourcekitd-test -req=cursor -pos=3:44 %s -- %s | %FileCheck %s
6+
7+
// CHECK: source.lang.swift.decl.function.free (3:6-3:68)
8+
// CHECK: logAsync(level:messageProducer:)
9+
// CHECK: LogLevel</Type> = &lt;&lt;empty&gt;&gt

0 commit comments

Comments
 (0)