mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[sourcekitd][AST] Fix CursorInfo crash on method with unresolved default value
When printing its annotated decl, we would would assume the param's default value is present if the default value kind was "Normal". The type checker explicitly sets the default value to nullptr if it doesn't type check though, so we were crashing for that case. Added the check. Resolves rdar://problem/46694149
This commit is contained in:
@@ -5101,6 +5101,14 @@ ParamDecl::getDefaultValueStringRepresentation(
|
||||
auto existing = DefaultValueAndFlags.getPointer()->StringRepresentation;
|
||||
if (!existing.empty())
|
||||
return existing;
|
||||
|
||||
if (!getDefaultValue()) {
|
||||
// TypeChecker::checkDefaultArguments() nulls out the default value
|
||||
// if it fails to type check it. This only seems to happen with an
|
||||
// invalid/incomplete parameter list that contains a parameter with an
|
||||
// unresolved default value.
|
||||
return "<<empty>>";
|
||||
}
|
||||
return extractInlinableText(getASTContext().SourceMgr, getDefaultValue(),
|
||||
scratch);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user