You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sema: Use VarDecl::isLayoutExposedToClients() when checking access in @Frozen structs
We require that all stored properties in a @Frozen struct have
public or @usableFromInline types, even if the property itself
is not public. This is so that clients can correctly generate
code to manipulate the @Frozen struct.
This check was only looking for bona-fide stored properties,
and missing out looking at properties that have backing storage,
namely 'lazy' properties and property wrappers.
privateclassPrivateType{} // expected-note {{class 'PrivateType' is not '@usableFromInline' or public}}
4
+
// expected-note@-1 {{initializer 'init()' is not '@usableFromInline' or public}}
5
+
// expected-note@-2 {{type declared here}}
6
+
7
+
@propertyWrapper
8
+
publicstructWrapper<T>{
9
+
publicinit(wrappedValue:T){}
10
+
11
+
publicvarwrappedValue:T{fatalError()}
12
+
}
13
+
14
+
@frozenpublicstructUsesPrivateType{
15
+
@Wrapperprivatevary1:PrivateType
16
+
// expected-error@-1 {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
17
+
18
+
@Wrapperprivatevary2=PrivateType()
19
+
// expected-error@-1 {{class 'PrivateType' is private and cannot be referenced from a property initializer in a '@frozen' type}}
20
+
// expected-error@-2 {{initializer 'init()' is private and cannot be referenced from a property initializer in a '@frozen' type}}
21
+
// expected-error@-3 {{type referenced from a stored property with inferred type 'PrivateType' in a '@frozen' struct must be '@usableFromInline' or public}}
0 commit comments