@@ -8,106 +8,154 @@ public struct Wrapper<T> {
8
8
}
9
9
10
10
@_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 {
12
21
// expected-note@-1 16{{class declared here}}
13
22
14
23
public init ( ) { }
15
24
}
16
25
17
- public struct ResilientStructSPIMembers {
26
+ public struct PublicType {
18
27
public init ( ) { }
19
28
20
- @_spi ( Foo) public func method ( _ : Bar ) { }
21
- @ _spi ( Foo ) public var computedProperty : Bar { Bar ( ) }
29
+ @_spi ( Foo) public func spiFunc ( ) { }
30
+ }
22
31
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
+ }
29
71
}
30
72
31
73
@frozen public struct FrozenStructSPIMembers {
32
74
public init ( ) { }
33
75
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 ( ) }
36
78
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}}
39
81
// expected-error@-2 {{stored property 'storedProperty1' cannot be declared '@_spi' in a '@frozen' struct}}
40
82
41
- @_spi ( Foo) public var storedProperty2 = Bar ( )
83
+ @_spi ( Foo) public var storedProperty2 = SPIType ( )
42
84
// expected-error@-1 {{stored property 'storedProperty2' cannot be declared '@_spi' in a '@frozen' struct}}
43
85
44
- @_spi ( Foo) public lazy var lazyProperty1 = Bar ( )
86
+ @_spi ( Foo) public lazy var lazyProperty1 = SPIType ( )
45
87
// expected-error@-1 {{stored property 'lazyProperty1' cannot be declared '@_spi' in a '@frozen' struct}}
46
88
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}}
49
91
// expected-error@-2 {{stored property 'lazyProperty2' cannot be declared '@_spi' in a '@frozen' struct}}
50
92
51
- @_spi ( Foo) @Wrapper public var wrappedProperty1 : Bar
93
+ @_spi ( Foo) @Wrapper public var wrappedProperty1 : SPIType
52
94
// expected-error@-1 {{stored property 'wrappedProperty1' cannot be declared '@_spi' in a '@frozen' struct}}
53
95
54
- @_spi ( Foo) @Wrapper public var wrappedProperty2 = Bar ( )
96
+ @_spi ( Foo) @Wrapper public var wrappedProperty2 = SPIType ( )
55
97
// 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}}
56
101
}
57
102
58
103
@frozen public struct FrozenStructPublicMembers {
59
104
public init ( ) { }
60
105
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}}
62
107
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}}
65
110
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}}
69
114
// expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
70
115
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}}
72
117
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}}
74
119
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}}
76
121
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}}
79
124
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}}
83
128
// 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}}
84
132
}
85
133
86
134
@frozen public struct FrozenStructPrivateMembers {
87
135
private init ( ) { }
88
136
89
- private func method( _: Bar ) { }
137
+ private func method( _: SPIType ) { }
90
138
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}}
93
141
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}}
97
145
// expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
98
146
99
- private var computedProperty : Bar { Bar ( ) }
147
+ private var computedProperty : SPIType { SPIType ( ) }
100
148
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}}
102
150
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}}
104
152
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}}
107
155
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}}
111
159
// expected-error@-3 {{initializer 'init()' cannot be used in a property initializer in a '@frozen' type because it is SPI}}
112
160
}
113
161
0 commit comments