mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] ASTPrinter: Don't print '@escaping' on 'inout' parameters
All of the `inout` types are implicitly `@escaping`.
(cherry picked from commit ee38182ae2)
This commit is contained in:
@@ -3907,8 +3907,11 @@ static void printParameterFlags(ASTPrinter &printer,
|
||||
printer.printKeyword("isolated", options, " ");
|
||||
}
|
||||
|
||||
if (!options.excludeAttrKind(TypeAttrKind::Escaping) && escaping)
|
||||
printer.printKeyword("@escaping", options, " ");
|
||||
// `inout` implies `@escaping`
|
||||
if (flags.getOwnershipSpecifier() != ParamSpecifier::InOut) {
|
||||
if (!options.excludeAttrKind(TypeAttrKind::Escaping) && escaping)
|
||||
printer.printKeyword("@escaping", options, " ");
|
||||
}
|
||||
|
||||
if (flags.isCompileTimeLiteral())
|
||||
printer.printKeyword("_const", options, " ");
|
||||
|
||||
@@ -1127,7 +1127,7 @@ func rdar17170728() {
|
||||
}
|
||||
|
||||
let _ = [i, j, k].reduce(0 as Int?) { // expected-error {{missing argument label 'into:' in call}}
|
||||
// expected-error@-1 {{cannot convert value of type 'Int?' to expected argument type '(inout @escaping (Bool, Bool) -> Bool?, Int?) throws -> ()'}}
|
||||
// expected-error@-1 {{cannot convert value of type 'Int?' to expected argument type '(inout (Bool, Bool) -> Bool?, Int?) throws -> ()'}}
|
||||
$0 && $1 ? $0 + $1 : ($0 ? $0 : ($1 ? $1 : nil))
|
||||
// expected-error@-1 {{binary operator '+' cannot be applied to two 'Bool' operands}}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ public struct TestWithAttrs {
|
||||
// CHECK-NEXT: public func test(_: nonisolated(nonsending) @escaping () async -> Swift.Void)
|
||||
// CHECK-NEXT: #endif
|
||||
public func test(_: nonisolated(nonsending) @escaping () async -> Void) {}
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $AsyncExecutionBehaviorAttributes
|
||||
// CHECK-NEXT: public func withInOut(fn: nonisolated(nonsending) inout () async -> Swift.Void)
|
||||
// CHECK-NEXT: #endif
|
||||
public func withInOut(fn: nonisolated(nonsending) inout () async -> Void) {}
|
||||
}
|
||||
|
||||
public struct Test {
|
||||
|
||||
Reference in New Issue
Block a user