Files
swift-mirror/test/decl/func/trailing_closures.swift
David Farler b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00

14 lines
862 B
Swift

// RUN: %target-typecheck-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}}
// 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