Files
swift-mirror/test/attr/closures.swift
Hamish Knight 2d6a38b2cd [CS] Call checkParameterList for single-expr closures
Previously we would only call this in the delayed
application logic, which is currently run for
multi-statement closures. I'm planning on
removing that code path, which uncovered this
issue.
2024-09-14 15:37:21 +01:00

25 lines
802 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 5
func testNonacceptedClosures() {
let fn = { @usableFromInline in // expected-error{{'usableFromInline' is not supported on a closure}}
"hello"
}
let fn2: (Int) -> Int = { @usableFromInline x in // expected-error{{'usableFromInline' is not supported on a closure}}
print("hello")
return x
}
_ = fn
_ = fn2
// https://github.com/swiftlang/swift/issues/76291
_ = { (@objc x: Int) in 0 } // expected-error {{'@objc' attribute cannot be applied to this declaration}}
_ = { (@objc x: Int) in } // expected-error {{'@objc' attribute cannot be applied to this declaration}}
_ = { (@objc x: Int) in // expected-error {{'@objc' attribute cannot be applied to this declaration}}
print("hello")
return x
}
}