Skip to content

Commit b059298

Browse files
authored
Merge pull request #38451 from bnbarham/5.5-cherry-rdar80546521
[5.5][SourceKit/DocInfo] Add is_async for properties with async getters
2 parents 4e2fdbc + 96952ac commit b059298

File tree

4 files changed

+61
-13
lines changed

4 files changed

+61
-13
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@import Foundation;
2+
3+
@interface AsyncImports : NSObject
4+
5+
-(void)methodWithCompletion:(void (^)(void))completionHandler;
6+
7+
-(void)propWithCompletion:(void (^)(BOOL))completionHandler
8+
__attribute__((swift_async_name("getter:asyncProp()")));
9+
10+
@end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module "asyncmod" {
2+
header "async.h"
3+
}
Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,88 @@
1-
// RUN: %empty-directory(%t.mod)
2-
// RUN: %swift -enable-experimental-concurrency -emit-module -o %t.mod/async.swiftmodule %s -parse-as-library -emit-module-doc-path %t.mod/async.swiftdoc
3-
// RUN: %sourcekitd-test -req=doc-info -module async -- -I %t.mod | %FileCheck %s
4-
51
// REQUIRES: concurrency
2+
// REQUIRES: objc_interop
3+
4+
// RUN: %sourcekitd-test -req=doc-info %s -- -module-name asyncmod -target %target-triple | %FileCheck %s
5+
6+
// RUN: %sourcekitd-test -req=doc-info -module asyncmod -- -target %target-triple %clang-importer-sdk-nosource -I %S/Inputs/async/ | %FileCheck %s --check-prefix=CHECK-OBJC
7+
// CHECK-OBJC: key.name: "method()",
8+
// CHECK-OBJC: key.usr: "c:objc(cs)AsyncImports(im)methodWithCompletion:"
9+
// CHECK-OBJC-NOT: },
10+
// CHECK-OBJC: key.is_async: 1
11+
// CHECK-OBJC: },
12+
13+
// CHECK-OBJC: key.name: "asyncProp",
14+
// CHECK-OBJC: key.usr: "c:objc(cs)AsyncImports(im)propWithCompletion:"
15+
// CHECK-OBJC: key.fully_annotated_decl:
16+
// CHECK-OBJC-NEXT: key.is_async: 1
17+
// CHECK-OBJC: }
618

719
public protocol AsyncProto {
20+
// CHECK: key.usr: "s:8asyncmod10AsyncProtoP05protoB4PropSivp"
21+
// CHECK-NOT: },
22+
// CHECK: key.is_async: 1
23+
// CHECK: },
24+
var protoAsyncProp: Int { get async }
25+
// CHECK: key.usr: "s:8asyncmod10AsyncProtoP08protoNonB4PropSivp"
26+
// CHECK-NOT: key.is_async: 1
27+
// CHECK: },
28+
var protoNonAsyncProp: Int { get }
29+
830
func protoAsyncFunc() async
9-
// CHECK: key.usr: "s:5async10AsyncProtoP05protoB4FuncyyYaF"
31+
// CHECK: key.usr: "s:8asyncmod10AsyncProtoP05protoB4FuncyyYaF"
1032
// CHECK-NOT: }
1133
// CHECK: key.is_async: 1
1234
// CHECK: }
1335
func protoNonAsyncFunc()
14-
// CHECK: key.usr: "s:5async10AsyncProtoP08protoNonB4FuncyyF"
36+
// CHECK: key.usr: "s:8asyncmod10AsyncProtoP08protoNonB4FuncyyF"
1537
// CHECK-NOT: key.is_async: 1
1638
// CHECK: }
1739
}
1840

1941
public struct AsyncStruct: AsyncProto {
42+
// CHECK: key.usr: "s:8asyncmod11AsyncStructV05protoB4PropSivp"
43+
// CHECK-NOT: },
44+
// CHECK: key.is_async: 1
45+
// CHECK: },
46+
public var protoAsyncProp: Int { get async { return 1 } }
47+
// CHECK: key.usr: "s:8asyncmod11AsyncStructV08protoNonB4PropSivp"
48+
// CHECK-NOT: key.is_async: 1
49+
// CHECK: },
50+
public var protoNonAsyncProp: Int
51+
2052
public func structAsyncFunc() async { }
21-
// CHECK: key.usr: "s:5async11AsyncStructV06structB4FuncyyYaF"
53+
// CHECK: key.usr: "s:8asyncmod11AsyncStructV06structB4FuncyyYaF"
2254
// CHECK-NOT: }
2355
// CHECK: key.is_async: 1
2456
// CHECK: }
2557
public func structNonAsyncFunc() { }
26-
// CHECK: key.usr: "s:5async11AsyncStructV09structNonB4FuncyyF"
58+
// CHECK: key.usr: "s:8asyncmod11AsyncStructV09structNonB4FuncyyF"
2759
// CHECK-NOT: key.is_async: 1
2860
// CHECK: }
2961

3062
public func protoAsyncFunc() async { }
31-
// CHECK: key.usr: "s:5async11AsyncStructV05protoB4FuncyyYaF"
63+
// CHECK: key.usr: "s:8asyncmod11AsyncStructV05protoB4FuncyyYaF"
3264
// CHECK-NOT: }
3365
// CHECK: key.conforms
3466
// CHECK: {
35-
// CHECK: key.usr: "s:5async10AsyncProtoP05protoB4FuncyyYaF"
67+
// CHECK: key.usr: "s:8asyncmod10AsyncProtoP05protoB4FuncyyYaF"
3668
// CHECK-NOT: }
3769
// CHECK: key.is_async: 1
3870
// CHECK: }
3971
// CHECK: key.is_async: 1
4072
// CHECK: }
4173
public func protoNonAsyncFunc() { }
42-
// CHECK: key.usr: "s:5async11AsyncStructV08protoNonB4FuncyyF"
74+
// CHECK: key.usr: "s:8asyncmod11AsyncStructV08protoNonB4FuncyyF"
4375
// CHECK-NOT: key.is_async: 1
4476
// CHECK: }
4577
}
4678

4779
public func topLevelAsyncFunc() async { }
48-
// CHECK: key.usr: "s:5async17topLevelAsyncFuncyyYaF"
80+
// CHECK: key.usr: "s:8asyncmod17topLevelAsyncFuncyyYaF"
4981
// CHECK-NOT: }
5082
// CHECK: key.is_async: 1
5183
// CHECK: }
5284
public func topLevelNonAsyncFunc() { }
53-
// CHECK: key.usr: "s:5async20topLevelNonAsyncFuncyyF"
85+
// CHECK: key.usr: "s:8asyncmod20topLevelNonAsyncFuncyyF"
5486
// CHECK-NOT: key.is_async: 1
5587
// CHECK: }
5688

tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,9 @@ static bool initDocEntityInfo(const Decl *D,
428428
Info.IsOptional = D->getAttrs().hasAttribute<OptionalAttr>();
429429
if (auto *AFD = dyn_cast<AbstractFunctionDecl>(D)) {
430430
Info.IsAsync = AFD->hasAsync();
431+
} else if (auto *Storage = dyn_cast<AbstractStorageDecl>(D)) {
432+
if (auto *Getter = Storage->getAccessor(AccessorKind::Get))
433+
Info.IsAsync = Getter->hasAsync();
431434
}
432435

433436
if (!IsRef) {

0 commit comments

Comments
 (0)