Skip to content

Commit

Permalink
[SyntaxParse] Fix AST source locations for function types
Browse files Browse the repository at this point in the history
Base location for function type should include leading trivia.
  • Loading branch information
rintaro committed Aug 27, 2019
1 parent 807e3f3 commit 5103789
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Parse/ParseType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Parser::TypeASTResult Parser::parseType(Diag<> MessageID,
return SILBoxType;
}

auto RealTypeLoc = Tok.getLoc();
auto RealTypeLoc = leadingTriviaLoc();

ParserResult<TypeRepr> ty =
parseTypeSimpleOrCompositionAST(MessageID, HandleCodeCompletion);
Expand Down
6 changes: 6 additions & 0 deletions test/Parse/function_type_range.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Ensure that source range for the type does not go past the end of the buffer.
// RUN: %target-swift-frontend -typecheck %s -dump-ast
typealias Alias =


() -> ()

0 comments on commit 5103789

Please sign in to comment.