Skip to content

Commit 5103789

Browse files
committed
[SyntaxParse] Fix AST source locations for function types
Base location for function type should include leading trivia.
1 parent 807e3f3 commit 5103789

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/Parse/ParseType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ Parser::TypeASTResult Parser::parseType(Diag<> MessageID,
362362
return SILBoxType;
363363
}
364364

365-
auto RealTypeLoc = Tok.getLoc();
365+
auto RealTypeLoc = leadingTriviaLoc();
366366

367367
ParserResult<TypeRepr> ty =
368368
parseTypeSimpleOrCompositionAST(MessageID, HandleCodeCompletion);

test/Parse/function_type_range.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Ensure that source range for the type does not go past the end of the buffer.
2+
// RUN: %target-swift-frontend -typecheck %s -dump-ast
3+
typealias Alias =
4+
5+
6+
() -> ()

0 commit comments

Comments
 (0)