@@ -8,106 +8,154 @@ public struct Wrapper<T> {
88}
99
1010@_spi ( Foo)
11- public class Bar {
11+ @propertyWrapper
12+ public struct SPIWrapper < T> {
13+ // expected-note@-1 2 {{generic struct declared here}}
14+ public init ( wrappedValue: T ) { }
15+
16+ public var wrappedValue : T { fatalError ( ) }
17+ }
18+
19+ @_spi ( Foo)
20+ public class SPIType {
1221 // expected-note@-1 16{{class declared here}}
1322
1423 public init ( ) { }
1524}
1625
17- public struct ResilientStructSPIMembers {
26+ public struct PublicType {
1827 public init ( ) { }
1928
20- @_spi ( Foo) public func method ( _ : Bar ) { }
21- @ _spi ( Foo ) public var computedProperty : Bar { Bar ( ) }
29+ @_spi ( Foo) public func spiFunc ( ) { }
30+ }
2231
23- @_spi ( Foo) public var storedProperty1 : Bar
24- @_spi ( Foo) public var storedProperty2 = Bar ( )
25- @_spi ( Foo) public lazy var lazyProperty1 = Bar ( )
26- @_spi ( Foo) public lazy var lazyProperty2 : Bar = Bar ( )
27- @_spi ( Foo) @Wrapper public var wrappedProperty1 : Bar
28- @_spi ( Foo) @Wrapper public var wrappedProperty2 = Bar ( )
32+ public struct ResilientStructSPIMembers {
33+ public init ( ) { }
34+
35+ @_spi ( Foo) public func method( _: SPIType ) { }
36+ @_spi ( Foo) public var computedProperty : SPIType { SPIType ( ) }
37+
38+ @_spi ( Foo) public var storedProperty1 : SPIType
39+ @_spi ( Foo) public var storedProperty2 = SPIType ( )
40+ @_spi ( Foo) public lazy var lazyProperty1 = SPIType ( )
41+ @_spi ( Foo) public lazy var lazyProperty2 : SPIType = SPIType ( )
42+ @_spi ( Foo) @Wrapper public var wrappedProperty1 : SPIType
43+ @_spi ( Foo) @Wrapper public var wrappedProperty2 = SPIType ( )
44+ @_spi ( Foo) @SPIWrapper public var wrappedProperty3 = SPIType ( )
45+
46+ @SPIWrapper public var wrappedProperty4 : PublicType
47+ // expected-error@-1 {{cannot use generic struct 'SPIWrapper' as property wrapper here; it is SPI}}
48+
49+ @_spi ( Foo) public var inlinableGet : Int {
50+ @inlinable
51+ get {
52+ let _ = SPIType ( )
53+ let t = PublicType ( )
54+ t. spiFunc ( )
55+ return 42
56+ }
57+ }
58+
59+ public var inlinablePublicGet : Int {
60+ @inlinable
61+ get {
62+ let _ = SPIType ( )
63+ // expected-error@-1 {{class 'SPIType' cannot be used in an '@inlinable' function because it is SPI}}
64+ // expected-error@-2 {{initializer 'init()' cannot be used in an '@inlinable' function because it is SPI}}
65+ let t = PublicType ( )
66+ t. spiFunc ( )
67+ // expected-error@-1 {{instance method 'spiFunc()' cannot be used in an '@inlinable' function because it is SPI}}
68+ return 42
69+ }
70+ }
2971}
3072
3173@frozen public struct FrozenStructSPIMembers {
3274 public init ( ) { }
3375
34- @_spi ( Foo) public func method( _: Bar ) { }
35- @_spi ( Foo) public var computedProperty : Bar { Bar ( ) }
76+ @_spi ( Foo) public func method( _: SPIType ) { }
77+ @_spi ( Foo) public var computedProperty : SPIType { SPIType ( ) }
3678
37- @_spi ( Foo) public var storedProperty1 : Bar
38- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
79+ @_spi ( Foo) public var storedProperty1 : SPIType
80+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
3981 // expected-error@-2 {{stored property 'storedProperty1' cannot be declared '@_spi' in a '@frozen' struct}}
4082
41- @_spi ( Foo) public var storedProperty2 = Bar ( )
83+ @_spi ( Foo) public var storedProperty2 = SPIType ( )
4284 // expected-error@-1 {{stored property 'storedProperty2' cannot be declared '@_spi' in a '@frozen' struct}}
4385
44- @_spi ( Foo) public lazy var lazyProperty1 = Bar ( )
86+ @_spi ( Foo) public lazy var lazyProperty1 = SPIType ( )
4587 // expected-error@-1 {{stored property 'lazyProperty1' cannot be declared '@_spi' in a '@frozen' struct}}
4688
47- @_spi ( Foo) public lazy var lazyProperty2 : Bar = Bar ( )
48- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
89+ @_spi ( Foo) public lazy var lazyProperty2 : SPIType = SPIType ( )
90+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
4991 // expected-error@-2 {{stored property 'lazyProperty2' cannot be declared '@_spi' in a '@frozen' struct}}
5092
51- @_spi ( Foo) @Wrapper public var wrappedProperty1 : Bar
93+ @_spi ( Foo) @Wrapper public var wrappedProperty1 : SPIType
5294 // expected-error@-1 {{stored property 'wrappedProperty1' cannot be declared '@_spi' in a '@frozen' struct}}
5395
54- @_spi ( Foo) @Wrapper public var wrappedProperty2 = Bar ( )
96+ @_spi ( Foo) @Wrapper public var wrappedProperty2 = SPIType ( )
5597 // expected-error@-1 {{stored property 'wrappedProperty2' cannot be declared '@_spi' in a '@frozen' struct}}
98+
99+ @_spi ( Foo) @SPIWrapper public var wrappedProperty3 = SPIType ( )
100+ // expected-error@-1 {{stored property 'wrappedProperty3' cannot be declared '@_spi' in a '@frozen' struct}}
56101}
57102
58103@frozen public struct FrozenStructPublicMembers {
59104 public init ( ) { }
60105
61- public func method( _: Bar ) { } // expected-error {{cannot use class 'Bar ' here; it is SPI}}
106+ public func method( _: SPIType ) { } // expected-error {{cannot use class 'SPIType ' here; it is SPI}}
62107
63- public var storedProperty1 : Bar
64- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
108+ public var storedProperty1 : SPIType
109+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
65110
66- public var storedProperty2 = Bar ( )
67- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
68- // expected-error@-2 {{class 'Bar ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
111+ public var storedProperty2 = SPIType ( )
112+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
113+ // expected-error@-2 {{class 'SPIType ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
69114 // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
70115
71- public var computedProperty : Bar { Bar ( ) } // expected-error {{cannot use class 'Bar ' here; it is SPI}}
116+ public var computedProperty : SPIType { SPIType ( ) } // expected-error {{cannot use class 'SPIType ' here; it is SPI}}
72117
73- public lazy var lazyProperty1 = Bar ( ) // expected-error {{cannot use class 'Bar ' here; it is SPI}}
118+ public lazy var lazyProperty1 = SPIType ( ) // expected-error {{cannot use class 'SPIType ' here; it is SPI}}
74119
75- public lazy var lazyProperty2 : Bar = Bar ( ) // expected-error {{cannot use class 'Bar ' here; it is SPI}}
120+ public lazy var lazyProperty2 : SPIType = SPIType ( ) // expected-error {{cannot use class 'SPIType ' here; it is SPI}}
76121
77- @Wrapper public var wrappedProperty1 : Bar
78- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
122+ @Wrapper public var wrappedProperty1 : SPIType
123+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
79124
80- @Wrapper public var wrappedProperty2 = Bar ( )
81- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
82- // expected-error@-2 {{class 'Bar ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
125+ @Wrapper public var wrappedProperty2 = SPIType ( )
126+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
127+ // expected-error@-2 {{class 'SPIType ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
83128 // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
129+
130+ @SPIWrapper public var wrappedProperty3 : PublicType
131+ // expected-error@-1 {{cannot use generic struct 'SPIWrapper' as property wrapper here; it is SPI}}
84132}
85133
86134@frozen public struct FrozenStructPrivateMembers {
87135 private init ( ) { }
88136
89- private func method( _: Bar ) { }
137+ private func method( _: SPIType ) { }
90138
91- private var storedProperty1 : Bar
92- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
139+ private var storedProperty1 : SPIType
140+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
93141
94- private var storedProperty2 = Bar ( )
95- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
96- // expected-error@-2 {{class 'Bar ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
142+ private var storedProperty2 = SPIType ( )
143+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
144+ // expected-error@-2 {{class 'SPIType ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
97145 // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
98146
99- private var computedProperty : Bar { Bar ( ) }
147+ private var computedProperty : SPIType { SPIType ( ) }
100148
101- private lazy var lazyProperty1 = Bar ( ) // expected-error {{cannot use class 'Bar ' here; it is SPI}}
149+ private lazy var lazyProperty1 = SPIType ( ) // expected-error {{cannot use class 'SPIType ' here; it is SPI}}
102150
103- private lazy var lazyProperty2 : Bar = Bar ( ) // expected-error {{cannot use class 'Bar ' here; it is SPI}}
151+ private lazy var lazyProperty2 : SPIType = SPIType ( ) // expected-error {{cannot use class 'SPIType ' here; it is SPI}}
104152
105- @Wrapper private var wrappedProperty1 : Bar
106- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
153+ @Wrapper private var wrappedProperty1 : SPIType
154+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
107155
108- @Wrapper private var wrappedProperty2 = Bar ( )
109- // expected-error@-1 {{cannot use class 'Bar ' here; it is SPI}}
110- // expected-error@-2 {{class 'Bar ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
156+ @Wrapper private var wrappedProperty2 = SPIType ( )
157+ // expected-error@-1 {{cannot use class 'SPIType ' here; it is SPI}}
158+ // expected-error@-2 {{class 'SPIType ' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
111159 // expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
112160}
113161
0 commit comments