You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// In Swift 5 mode either f or g can be used as a trailing closure.
96
+
// In Swift 6 mode only f can be used as a trailing closure.
97
+
func trailingClosureEitherDirection(
98
+
f:(Int)->Int={ $0 }, g:(Int,Int)->Int={ $0 + $1 }
99
+
){}
100
+
101
+
func testTrailingClosureEitherDirection(){
102
+
trailingClosureEitherDirection{-$0 }
103
+
trailingClosureEitherDirection{ $0 * $1 } // expected-error{{contextual closure type '(Int) -> Int' expects 1 argument, but 2 were used in closure body}}
104
+
}
105
+
106
+
// This example was allowed as a trailing closure in Swift 5 mode but is no longer allowed in Swift 6 mode
_ =AccidentalReorder(optionalInt:17){42} // expected-warning{{backward matching of the unlabeled trailing closure is deprecated; label the argument with 'content' to suppress this warning}}
_ =BlockObserver{ _, _, _ in} // expected-warning {{backward matching of the unlabeled trailing closure is deprecated; label the argument with 'finishHandler' to suppress this warning}}
0 commit comments