mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Support trailing commas in types within expressions
This commit is contained in:
@@ -1609,7 +1609,8 @@ bool Parser::canParseGenericArguments() {
|
||||
if (!canParseType())
|
||||
return false;
|
||||
// Parse the comma, if the list continues.
|
||||
} while (consumeIf(tok::comma));
|
||||
// This could be the trailing comma.
|
||||
} while (consumeIf(tok::comma) && !startsWithGreater(Tok));
|
||||
|
||||
if (!startsWithGreater(Tok)) {
|
||||
return false;
|
||||
|
||||
@@ -102,7 +102,7 @@ struct Foo {
|
||||
|
||||
}
|
||||
|
||||
func f(in: @differentiable(reverse,) (Int) -> Int) { } // expected-warning {{@differentiable' has been renamed to '@differentiable(reverse)' and will be removed in the next release}} expected-error {{unexpected ',' separator}} expected-error {{expected ',' separator}} expected-error {{unnamed parameters must be written with the empty name '_'}}
|
||||
func f(in: @differentiable(reverse,) (Int) -> Int) { } // expected-warning {{@differentiable' has been renamed to '@differentiable(reverse)' and will be removed in the next release}} expected-error {{expected ',' separator}} expected-error {{unnamed parameters must be written with the empty name '_'}}
|
||||
|
||||
@derivative(of: Self.other,) // expected-error {{unexpected ',' separator}}
|
||||
func foo() {}
|
||||
@@ -144,7 +144,7 @@ while true, { } // expected-error {{expected '{' after 'while' condition}}
|
||||
if #available(OSX 51,) { // expected-error {{expected platform name}}
|
||||
}
|
||||
|
||||
@available(OSX 10.7, iOS 7.0, *,) // expected-error {{expected platform name}}
|
||||
@available(OSX 10.7, iOS 7.0, *,) // expected-error {{expected platform name}} expected-error {{expected declaration}}
|
||||
@_originallyDefinedIn(module: "HighLevel", OSX 10.9, iOS 13.0,) // expected-error {{unexpected ',' separator}}
|
||||
@backDeployed(before: OSX 10.9,) // expected-error {{expected version number in '@backDeployed' attribute}}
|
||||
@backDeployed(before: OSX 10.9,) // expected-error {{unexpected ',' separator}}
|
||||
public struct StructWithAvailability {}
|
||||
|
||||
@@ -88,3 +88,6 @@ typealias Bar2<
|
||||
T2,
|
||||
Bool,
|
||||
>
|
||||
|
||||
let _ = Foo2<Int, Bool, String,>.self
|
||||
let _ = Bar2<Int, Bool,>()
|
||||
|
||||
@@ -225,6 +225,8 @@ let tupleTypeWithTrailingComma: (
|
||||
quux: String,
|
||||
)
|
||||
|
||||
let _ = (bar: String, quux: String,).self
|
||||
|
||||
let closureTypeWithTrailingCommas: (
|
||||
String,
|
||||
String,
|
||||
|
||||
Reference in New Issue
Block a user