[AST] Adjust usesFeatureExecutionAttribute to cover accessors

This commit is contained in:
Pavel Yaskevich
2025-03-14 17:29:26 -07:00
parent eeabaaee6c
commit bb6326bb32
2 changed files with 47 additions and 0 deletions

View File

@@ -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;

View File

@@ -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
}
}
}