File tree 2 files changed +17
-15
lines changed
2 files changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -848,20 +848,20 @@ void Parser::parseAsyncThrows(
848
848
diagnose (Tok, diag::throw_in_function_type)
849
849
.fixItReplace (Tok.getLoc (), " throws" );
850
850
}
851
-
852
- StringRef keyword = Tok.getText ();
853
- throwsLoc = consumeToken ();
854
-
855
- if (! peekToken (). isKeyword ()) {
856
- BacktrackingScope backtrackingScope (* this );
857
- if ( peekToken (). is (tok::kw_throws)) {
858
- ASTContext &Ctx = SF. getASTContext ();
859
- DiagnosticSuppression SuppressedDiags (Ctx. Diags );
860
- backtrackingScope. cancelBacktrack ();
861
- if ( canParseType ()) {
862
- ParserResult<TypeRepr> result = parseType ();
863
- throwsType = result. getPtrOrNull ();
864
- }
851
+ StringRef keyword;
852
+ if (Tok. isKeyword () && Tok.is (tok::kw_throws)) {
853
+ keyword = Tok. getText ();
854
+ throwsLoc = consumeToken ();
855
+ ASTContext &Ctx = SF. getASTContext ();
856
+ DiagnosticSuppression SuppressedDiags (Ctx. Diags );
857
+ bool hasType = false ;
858
+ {
859
+ BacktrackingScope backtrack (* this );
860
+ hasType = canParseType ();
861
+ }
862
+ if (hasType) {
863
+ ParserResult<TypeRepr> result = parseType ();
864
+ throwsType = result. getPtrOrNull ();
865
865
}
866
866
}
867
867
Original file line number Diff line number Diff line change @@ -42,9 +42,11 @@ func one() {
42
42
43
43
func foo( ) throws { }
44
44
45
- struct SomeError : Error { }
45
+ struct SomeError : Swift . Error { }
46
46
47
47
func bar( ) throws SomeError { }
48
+
49
+ func baz( ) throws SomeError -> Int { return 2 ; }
48
50
49
51
do {
50
52
#if false
You can’t perform that action at this time.
0 commit comments