mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Adjust usesFeatureExecutionAttribute to cover accessors
This commit is contained in:
@@ -466,6 +466,12 @@ static bool usesFeatureBuiltinEmplaceTypedThrows(Decl *decl) {
|
||||
}
|
||||
|
||||
static bool usesFeatureExecutionAttribute(Decl *decl) {
|
||||
if (auto *ASD = dyn_cast<AbstractStorageDecl>(decl)) {
|
||||
if (auto *getter = ASD->getAccessor(AccessorKind::Get))
|
||||
return usesFeatureExecutionAttribute(getter);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (decl->getAttrs().hasAttribute<ExecutionAttr>())
|
||||
return true;
|
||||
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
// REQUIRES: swift_feature_ExecutionAttribute
|
||||
|
||||
public struct Test {
|
||||
// CHECK: #if compiler(>=5.3) && $ExecutionAttribute
|
||||
// CHECK-NEXT: @execution(caller) public init() async
|
||||
// CHECK-NEXT: #else
|
||||
// CHECK-NEXT: public init() async
|
||||
// CHECK-NEXT: #endif
|
||||
@execution(caller)
|
||||
public init() async {
|
||||
}
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $ExecutionAttribute
|
||||
// CHECK-NEXT: @execution(concurrent) public func test() async
|
||||
// CHECK-NEXT: #else
|
||||
@@ -21,5 +30,37 @@ public struct Test {
|
||||
// CHECK-NEXT: public func other(_: () async -> Swift.Void)
|
||||
// CHECK-NEXT: #endif
|
||||
public func other(_: @execution(caller) () async -> Void) {}
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $ExecutionAttribute
|
||||
// CHECK-NEXT: public var test: Swift.Int {
|
||||
// CHECK-NEXT: @execution(caller) get async
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: #else
|
||||
// CHECK-NEXT: public var test: Swift.Int {
|
||||
// CHECK-NEXT: get async
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: #endif
|
||||
public var test: Int {
|
||||
@execution(caller)
|
||||
get async {
|
||||
42
|
||||
}
|
||||
}
|
||||
|
||||
// CHECK: #if compiler(>=5.3) && $ExecutionAttribute
|
||||
// CHECK-NEXT: public subscript(x: Swift.Int) -> Swift.Bool {
|
||||
// CHECK-NEXT: @execution(caller) get async
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: #else
|
||||
// CHECK-NEXT: public subscript(x: Swift.Int) -> Swift.Bool {
|
||||
// CHECK-NEXT: get async
|
||||
// CHECK-NEXT: }
|
||||
// CHECK-NEXT: #endif
|
||||
public subscript(x: Int) -> Bool {
|
||||
@execution(caller)
|
||||
get async {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user