File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -1747,17 +1747,19 @@ bool Parser::canParseNonisolatedAsTypeModifier() {
17471747 if (Tok.isAtStartOfLine ())
17481748 return false ;
17491749
1750- // Always requires `(<<argument>>)`
1751- if (!Tok.is (tok::l_paren))
1750+ // Always requires `(nonsending)`, together
1751+ // we don't want eagerly interpret something
1752+ // like `nonisolated(0)` as a modifier.
1753+
1754+ if (!consumeIf (tok::l_paren))
17521755 return false ;
17531756
1754- // Consume argument list
1755- skipSingle () ;
1757+ if (!Tok. isContextualKeyword ( " nonsending " ))
1758+ return false ;
17561759
1757- // if consumed '(...)' ended up being followed
1758- // by `[async, throws, ...] -> ...` this means
1759- // the `nonisolated` is invalid as a modifier.
1760- return !isAtFunctionTypeArrow ();
1760+ consumeToken ();
1761+
1762+ return consumeIf (tok::r_paren);
17611763}
17621764
17631765bool Parser::canParseTypeScalar () {
Original file line number Diff line number Diff line change 7777
7878 _ = [ nonisolated ( ) ]
7979}
80+
81+ do {
82+ func nonisolated( _: Int ) -> Int { 42 }
83+
84+ nonisolated ( 0 ) // expected-warning {{result of call to 'nonisolated' is unused}}
85+ print ( " hello " )
86+ }
You can’t perform that action at this time.
0 commit comments