Skip to content

Commit 683f681

Browse files
authored
Merge pull request #72037 from hborla/global-actor-cursor-info
[Concurrency] Never skip global actor attributes in the ASTPrinter.
2 parents 70f4202 + ba76c3c commit 683f681

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

lib/AST/Attr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,12 @@ void DeclAttributes::print(ASTPrinter &Printer, const PrintOptions &Options,
960960
AttributeVector modifiers;
961961

962962
for (auto DA : llvm::reverse(FlattenedAttrs)) {
963-
// Always print result builder attribute.
964-
if (!Options.PrintImplicitAttrs && DA->isImplicit())
963+
// Don't skip implicit custom attributes. Custom attributes like global
964+
// actor isolation have critical semantic meaning and should never be
965+
// suppressed. Other custom attrs that can be suppressed, like macros,
966+
// are handled below.
967+
if (DA->getKind() != DeclAttrKind::Custom &&
968+
!Options.PrintImplicitAttrs && DA->isImplicit())
965969
continue;
966970
if (!Options.PrintUserInaccessibleAttrs &&
967971
DeclAttribute::isUserInaccessible(DA->getKind()))
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@MainActor
2+
protocol P {}
3+
4+
class InferMainActor: P {
5+
func test() {}
6+
}
7+
8+
// RUN: %sourcekitd-test -req=cursor -pos=4:7 %s -- %s -module-name ConcurrencyTest | %FileCheck %s --check-prefix=CHECK-CLASS
9+
// CHECK-CLASS: source.lang.swift.decl.class
10+
// CHECK-CLASS-NEXT: InferMainActor
11+
// CHECK-CLASS: <Declaration>@<Type usr="s:ScM">MainActor</Type> class InferMainActor : <Type usr="s:15ConcurrencyTest1PP">P</Type></Declaration>
12+
// CHECK-CLASS: <decl.class><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@<ref.class usr="s:ScM">MainActor</ref.class></syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>class</syntaxtype.keyword> <decl.name>InferMainActor</decl.name> : <ref.protocol usr="s:15ConcurrencyTest1PP">P</ref.protocol></decl.class>
13+
14+
// RUN: %sourcekitd-test -req=cursor -pos=5:8 %s -- %s -module-name ConcurrencyTest | %FileCheck %s --check-prefix=CHECK-FUNC
15+
// CHECK-FUNC: source.lang.swift.decl.function.method.instance
16+
// CHECK-FUNC-NEXT: test()
17+
// CHECK-FUNC: <Declaration>@<Type usr="s:ScM">MainActor</Type> func test()</Declaration>
18+
// CHECK-FUNC: <decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@<ref.class usr="s:ScM">MainActor</ref.class></syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>test</decl.name>()</decl.function.method.instance>

0 commit comments

Comments
 (0)