Skip to content

Commit 5c11a4b

Browse files
committed
[ASTPrinter] TypeWrappers: print inferred attributes
1 parent 2ce48e0 commit 5c11a4b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,16 @@ void PrintAST::printAttributes(const Decl *D) {
11791179

11801180
D->getAttrs().print(Printer, Options, D);
11811181

1182+
// We need to check whether this is a type with an inferred
1183+
// type wrapper attribute and if so print it explicitly.
1184+
if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
1185+
auto typeWrapperInfo = NTD->getTypeWrapper();
1186+
// The attribute has been inferred and we have to print it.
1187+
if (typeWrapperInfo && typeWrapperInfo->IsInferred) {
1188+
typeWrapperInfo->Attr->print(Printer, Options, D);
1189+
}
1190+
}
1191+
11821192
// Print the implicit 'final' attribute.
11831193
if (auto VD = dyn_cast<ValueDecl>(D)) {
11841194
auto VarD = dyn_cast<VarDecl>(D);

test/ModuleInterface/type_wrappers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public protocol Wrapped {
4646

4747
public protocol OuterWrapped : Wrapped {}
4848

49-
// CHECK: public struct WithProtocol : TypeWrappers.Wrapped {
49+
// CHECK: @TypeWrappers.Wrapper public struct WithProtocol : TypeWrappers.Wrapped {
5050
// CHECK: public var a: Swift.Int {
5151
// CHECK: get
5252
// CHECK: set

0 commit comments

Comments
 (0)