mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The `asyncHandler` attribute turned out to be the wrong solution to the problem of creating a sync->async bridge. Remove it.
56 lines
1.8 KiB
Swift
56 lines
1.8 KiB
Swift
// RUN: %target-typecheck-verify-swift -enable-experimental-concurrency
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
protocol AsyncProtocol {
|
|
func asyncMethod() async -> Int
|
|
}
|
|
|
|
actor MyActor {
|
|
}
|
|
|
|
// Actors conforming to asynchronous program.
|
|
extension MyActor: AsyncProtocol {
|
|
func asyncMethod() async -> Int { return 0 }
|
|
}
|
|
|
|
protocol SyncProtocol {
|
|
var propertyA: Int { get }
|
|
var propertyB: Int { get set }
|
|
|
|
func syncMethodA()
|
|
|
|
func syncMethodC() -> Int
|
|
|
|
subscript (index: Int) -> String { get }
|
|
|
|
static func staticMethod()
|
|
static var staticProperty: Int { get }
|
|
}
|
|
|
|
|
|
actor OtherActor: SyncProtocol {
|
|
var propertyB: Int = 17
|
|
// expected-error@-1{{actor-isolated property 'propertyB' cannot be used to satisfy a protocol requirement}}
|
|
|
|
var propertyA: Int { 17 }
|
|
// expected-error@-1{{actor-isolated property 'propertyA' cannot be used to satisfy a protocol requirement}}
|
|
// expected-note@-2{{add 'nonisolated' to 'propertyA' to make this property not isolated to the actor}}{{3-3=nonisolated }}
|
|
|
|
func syncMethodA() { }
|
|
// expected-error@-1{{actor-isolated instance method 'syncMethodA()' cannot be used to satisfy a protocol requirement}}
|
|
// expected-note@-2{{add 'nonisolated' to 'syncMethodA()' to make this instance method not isolated to the actor}}{{3-3=nonisolated }}
|
|
|
|
// nonisolated methods are okay.
|
|
// FIXME: Consider suggesting nonisolated if this didn't match.
|
|
nonisolated func syncMethodC() -> Int { 5 }
|
|
|
|
subscript (index: Int) -> String { "\(index)" }
|
|
// expected-error@-1{{actor-isolated subscript 'subscript(_:)' cannot be used to satisfy a protocol requirement}}
|
|
// expected-note@-2{{add 'nonisolated' to 'subscript(_:)' to make this subscript not isolated to the actor}}{{3-3=nonisolated }}
|
|
|
|
// Static methods and properties are okay.
|
|
static func staticMethod() { }
|
|
static var staticProperty: Int = 17
|
|
}
|