mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This means properties returning noncopyable types or those marked with `@_borrowed` can't have effects. The compiler never accepted the latter correctly before. The synthesized coroutine `read` calls the user-defined `get`, but coroutines don't support `async` or `throws`. resolves rdar://106260787
31 lines
902 B
Swift
31 lines
902 B
Swift
// RUN: %target-typecheck-verify-swift -disable-availability-checking
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: concurrency
|
|
|
|
import Foundation
|
|
|
|
@_borrowed // expected-error {{'@_borrowed' attribute cannot be applied to this declaration}}
|
|
func foo() -> String {}
|
|
|
|
@_borrowed
|
|
var string = ""
|
|
|
|
@objc protocol P {
|
|
@_borrowed // expected-error {{property cannot be '@_borrowed' if it is an @objc protocol requirement}}
|
|
var title: String { get }
|
|
}
|
|
|
|
@objc class A {
|
|
@_borrowed // expected-error {{property cannot be '@_borrowed' if it is '@objc dynamic'}}
|
|
@objc dynamic var title: String { return "" }
|
|
}
|
|
|
|
public class Holder {
|
|
@_borrowed var one: String {
|
|
get async { "" } // expected-error {{getter cannot be '@_borrowed' if it is 'async' or 'throws'}}
|
|
}
|
|
@_borrowed var two: String {
|
|
get throws { "" } // expected-error {{getter cannot be '@_borrowed' if it is 'async' or 'throws'}}
|
|
}
|
|
}
|