Files
swift-mirror/test/attr/attr_fixed_layout_class.swift
Slava Pestov 01bc774061 Sema: Enforce that stored properties of @_fixed_layout classes only reference public types
This is the same restriction as with @frozen structs. Even though
classes are lowered as a single reference and clients don't usually
manipulate their stored property layout directly, @frozen classes
can have @inlinable designated initializers.
2020-10-22 01:11:56 -04:00

19 lines
969 B
Swift

// RUN: %target-typecheck-verify-swift -swift-version 5
private struct PrivateType {}
// expected-note@-1 {{struct 'PrivateType' is not '@usableFromInline' or public}}
// expected-note@-2 {{initializer 'init()' is not '@usableFromInline' or public}}
// expected-note@-3 {{type declared here}}
@_fixed_layout public class UsesPrivateType {
private var y1: PrivateType
// expected-error@-1 {{type referenced from a stored property in a '@frozen' struct must be '@usableFromInline' or public}}
private var y2 = PrivateType()
// expected-error@-1 {{struct 'PrivateType' is private and cannot be referenced from a property initializer in a '@frozen' type}}
// expected-error@-2 {{initializer 'init()' is private and cannot be referenced from a property initializer in a '@frozen' type}}
// expected-error@-3 {{type referenced from a stored property with inferred type 'PrivateType' in a '@frozen' struct must be '@usableFromInline' or public}}
init() {}
}