Skip to content

Commit 1c8cf3f

Browse files
committed
fix missing effects specifiers on eff props in swiftinterface
I missed the case where the body is also being printed in the interface file.
1 parent b617797 commit 1c8cf3f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3496,6 +3496,10 @@ void PrintAST::visitAccessorDecl(AccessorDecl *decl) {
34963496
});
34973497
}
34983498

3499+
// handle effects specifiers before the body
3500+
if (decl->hasAsync()) Printer << " async";
3501+
if (decl->hasThrows()) Printer << " throws";
3502+
34993503
printBodyIfNecessary(decl);
35003504
}
35013505

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %target-swift-frontend -enable-experimental-concurrency -typecheck -swift-version 5 -enable-library-evolution -emit-module-interface-path %t.swiftinterface %s -module-name EffProps
2+
// RUN: %FileCheck %s < %t.swiftinterface
3+
4+
public struct MyStruct {}
5+
6+
// CHECK-LABEL: public var status
7+
// CHECK: get async throws
8+
9+
public extension MyStruct {
10+
struct InnerStruct {
11+
public var status: Bool { get async throws { false } }
12+
}
13+
}
14+
15+
// CHECK-LABEL: public var hello
16+
// CHECK: get async
17+
18+
// CHECK-LABEL: public subscript
19+
// CHECK: get async throws
20+
21+
public class C {
22+
public var hello: Int { get async { 0 } }
23+
24+
public subscript(_ x: Int) -> Void {
25+
get async throws { }
26+
}
27+
}
28+
29+
// CHECK-LABEL: public var world
30+
// CHECK: get throws
31+
32+
public enum E {
33+
public var world: Int { get throws { 0 } }
34+
}

0 commit comments

Comments
 (0)