mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This finds cases where something that used to be a trailing closure is no longer a trailing closure due to the recent rule change. Swift SVN r25289
15 lines
1021 B
Swift
15 lines
1021 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
// Warn about non-trailing closures followed by parameters with
|
|
// default arguments.
|
|
func f1(f: () -> (), bar: Int = 10) { } // expected-warning{{closure parameter prior to parameters with default arguments will not be treated as a trailing closure}}
|
|
func f2(f: (() -> ())!, bar: Int = 10, wibble: Int = 17) { } // expected-warning{{closure parameter prior to parameters with default arguments will not be treated as a trailing closure}}
|
|
func f3(f: (() -> ())?, bar: Int = 10) { } // expected-warning{{closure parameter prior to parameters with default arguments will not be treated as a trailing closure}}
|
|
func f4(var f: (() -> ())?, bar: Int = 10) { } // expected-warning{{closure parameter prior to parameters with default arguments will not be treated as a trailing closure}}
|
|
|
|
// An extra set of parentheses suppresses the warning.
|
|
func g1(f: (() -> ()), bar: Int = 10) { } // no-warning
|
|
|
|
// Stop at the first closure.
|
|
func g2(f: () -> (), g: (() -> ())? = nil) { } // no-warning
|