mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This flips the switch to have @noescape be the default semantics for function types in argument positions, for everything except property setters. Property setters are naturally escaping, so they keep their escaping-by-default behavior. Adds contentual printing, and updates the test cases. There is some further (non-source-breaking) work to be done for SE-0103: - We need the withoutActuallyEscaping function - Improve diagnostics and QoI to at least @noescape's standards - Deprecate / drop @noescape, right now we allow it - Update internal code completion printing to be contextual - Add more tests to explore tricky corner cases - Small regressions in fixits in attr/attr_availability.swift
16 lines
601 B
Swift
16 lines
601 B
Swift
// RUN: %target-swift-frontend %s -emit-ir -verify
|
|
|
|
// Verify we don't crash on this.
|
|
// rdar://15595118
|
|
infix operator ~>
|
|
protocol Target {}
|
|
|
|
func ~> <Target, Arg0, Result>(x: inout Target, f: @escaping (_: inout Target, _: Arg0) -> Result) -> (Arg0) -> Result {
|
|
return { f(&x, $0) } // expected-error {{escaping closures can only capture inout parameters explicitly by value}}
|
|
}
|
|
|
|
func ~> (x: inout Int, f: @escaping (_: inout Int, _: Target) -> Target) -> (Target) -> Target {
|
|
return { f(&x, $0) } // expected-error {{escaping closures can only capture inout parameters explicitly by value}}
|
|
}
|
|
|