Skip to content

Commit b6291e6

Browse files
authored
Merge pull request #85736 from xedin/rdar-122963120
[ASTPrinter] Print a fully resolved type for an outermost property wr…
2 parents 76c0e12 + 5b665a8 commit b6291e6

File tree

3 files changed

+46
-8
lines changed

3 files changed

+46
-8
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4870,7 +4870,9 @@ void PrintAST::visitMacroExpansionDecl(MacroExpansionDecl *decl) {
48704870
void CustomAttr::printCustomAttr(ASTPrinter &Printer, const PrintOptions &Options) const {
48714871
Printer.callPrintNamePre(PrintNameContext::Attribute);
48724872
Printer << "@";
4873-
if (auto type = getType())
4873+
if (auto *init = getSemanticInit(); init && Options.IsForSwiftInterface)
4874+
init->getType().print(Printer, Options);
4875+
else if (auto type = getType())
48744876
type.print(Printer, Options);
48754877
else
48764878
getTypeRepr()->print(Printer, Options);

test/ModuleInterface/property_wrapper_availability.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public struct UnavailableWrapper<T> {
2929
// CHECK: public struct HasWrappers {
3030
public struct HasWrappers {
3131
// CHECK: @available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *)
32-
// CHECK-NEXT: @Library.ConditionallyAvailableWrapper public var x: Swift.Int {
32+
// CHECK-NEXT: @Library.ConditionallyAvailableWrapper<Swift.Int> public var x: Swift.Int {
3333
// CHECK-NEXT: get
3434
// CHECK-NEXT: @available(iOS 13.4, tvOS 13.4, watchOS 6.2, macOS 10.15.4, *)
3535
// CHECK-NEXT: set
@@ -50,7 +50,7 @@ public struct HasWrappers {
5050
@available(watchOS, unavailable)
5151
@available(tvOS, unavailable)
5252
public struct UnavailableHasWrappers {
53-
// CHECK-LABEL: @Library.UnavailableWrapper public var x: Swift.Int {
53+
// CHECK-LABEL: @Library.UnavailableWrapper<Swift.Int> public var x: Swift.Int {
5454
// CHECK-NEXT: get
5555
// CHECK-NEXT: @available(iOS, unavailable)
5656
// CHECK-NEXT: @available(tvOS, unavailable)

test/ModuleInterface/property_wrappers.swift

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,24 @@ public struct ProjectedValueWrapper<T> {
5252
}
5353
}
5454

55+
@propertyWrapper public struct HasTwoTypeParameters<Value, Other> {
56+
public var wrappedValue: Value
57+
58+
init(wrappedValue: Value, _ other: Other) {
59+
fatalError()
60+
}
61+
}
62+
5563
// CHECK: public struct HasWrappers {
5664
public struct HasWrappers {
57-
// CHECK: @TestResilient.Wrapper public var x: {{(Swift.)?}}Int {
65+
// CHECK: @TestResilient.Wrapper<Swift.Int> public var x: {{(Swift.)?}}Int {
5866
// CHECK-NEXT: get
5967
// CHECK-NEXT: set
6068
// CHECK-NEXT: _modify
6169
// CHECK-NEXT: }
6270
@Wrapper public var x: Int
6371

64-
// CHECK: @TestResilient.WrapperWithInitialValue @_projectedValueProperty($y) public var y: Swift.Int {
72+
// CHECK: @TestResilient.WrapperWithInitialValue<Swift.Int> @_projectedValueProperty($y) public var y: Swift.Int {
6573
// CHECK-NEXT: get
6674
// CHECK-NEXT: }
6775
@WrapperWithInitialValue public private(set) var y = 17
@@ -70,13 +78,41 @@ public struct HasWrappers {
7078
// CHECK-NEXT: get
7179
// CHECK-NEXT: }
7280

73-
// CHECK: @TestResilient.WrapperWithInitialValue @_projectedValueProperty($z) public var z: Swift.Bool {
81+
// CHECK: @TestResilient.HasTwoTypeParameters<Swift.Int, Swift.String> public var w1: Swift.Int {
82+
// CHECK-NEXT: get
83+
// CHECK-NEXT: set
84+
// CHECK-NEXT: _modify
85+
// CHECK-NEXT: }
86+
@HasTwoTypeParameters(wrappedValue: 0, "other") public var w1: Int
87+
88+
// CHECK: @TestResilient.HasTwoTypeParameters<Swift.Int, Swift.String> public var w2: Swift.Int {
89+
// CHECK-NEXT: get
90+
// CHECK-NEXT: set
91+
// CHECK-NEXT: _modify
92+
// CHECK-NEXT: }
93+
@HasTwoTypeParameters("other") public var w2: Int = 0
94+
95+
// CHECK: @TestResilient.HasTwoTypeParameters<TestResilient.HasTwoTypeParameters<Swift.Int, Swift.Double>, Swift.String> @TestResilient.HasTwoTypeParameters public var w3: Swift.Int {
96+
// CHECK-NEXT: get
97+
// CHECK-NEXT: set
98+
// CHECK-NEXT: _modify
99+
// CHECK-NEXT: }
100+
@HasTwoTypeParameters("a") @HasTwoTypeParameters(1.0) public var w3: Int = 0
101+
102+
// CHECK: @TestResilient.WrapperWithInitialValue<Swift.Bool> @_projectedValueProperty($z) public var z: Swift.Bool {
74103
// CHECK-NEXT: get
75104
// CHECK-NEXT: set
76105
// CHECK-NEXT: _modify
77106
// CHECK-NEXT: }
78107
@WrapperWithInitialValue(alternate: false) public var z
79108

109+
// CHECK: @TestResilient.HasTwoTypeParameters<TestResilient.Wrapper<Swift.Int>, Swift.String> @TestResilient.Wrapper public var composed: Swift.Int {
110+
// CHECK-NEXT: get
111+
// CHECK-NEXT: set
112+
// CHECK-NEXT: _modify
113+
// CHECK-NEXT: }
114+
@HasTwoTypeParameters("other") @Wrapper public var composed: Int = 42
115+
80116
// CHECK: public func hasParameterWithImplementationWrapper(x: Swift.Int)
81117
public func hasParameterWithImplementationWrapper(@Wrapper x: Int) { }
82118

@@ -89,9 +125,9 @@ public struct HasWrappers {
89125
// CHECK: @_alwaysEmitIntoClient public func hasParameterWithImplementationWrapperAEIC(@TestResilient.Wrapper x: Swift.Int)
90126
@_alwaysEmitIntoClient public func hasParameterWithImplementationWrapperAEIC(@Wrapper x: Int) { }
91127

92-
// CHECK: public func hasParameterWithAPIWrapper(@TestResilient.ProjectedValueWrapper x: Swift.Int)
128+
// CHECK: public func hasParameterWithAPIWrapper(@TestResilient.ProjectedValueWrapper<Swift.Int> x: Swift.Int)
93129
public func hasParameterWithAPIWrapper(@ProjectedValueWrapper x: Int) { }
94130

95-
// CHECK: public func hasParameterWithAPIWrapperComposed(@TestResilient.ProjectedValueWrapper @TestResilient.Wrapper x: Swift.Int)
131+
// CHECK: public func hasParameterWithAPIWrapperComposed(@TestResilient.ProjectedValueWrapper<TestResilient.Wrapper<Swift.Int>> @TestResilient.Wrapper x: Swift.Int)
96132
public func hasParameterWithAPIWrapperComposed(@ProjectedValueWrapper @Wrapper x: Int) { }
97133
}

0 commit comments

Comments
 (0)