Files
swift-mirror/test/Sema/package_frozen_fixed_layout.swift
Ellie Shin 573d1b96ca Allow @frozen and @_fixed_layout for package access level.
Package decls were made to be resilient at the definition
site by default. By allowing the attributes to be applied
to package decls, we can enable non-resilient access.

Resolves rdar://125169361
2024-04-18 16:29:34 -07:00

45 lines
1.1 KiB
Swift

// RUN: %target-swift-frontend -typecheck %s -I %t -swift-version 5 -package-name mypkg -verify
package struct PkgStruct {
package var one: Int
package var two: String
package func f() {}
}
@frozen
package struct FrozenPkgStruct {
package var one: Int
package var two: String
package func f() {}
}
@frozen
@usableFromInline
package struct FrozenUfiPkgStruct {
package var one: Int
package var two: String
package func f() {}
}
@frozen // expected-error {{'@frozen' attribute can only be applied to '@usableFromInline', package, or public declarations, but 'FrozenInternalStruct' is internal}} {{1-9=}}
struct FrozenInternalStruct {
var one: Int
var two: String
func f() {}
}
@_fixed_layout
package class FixedPkgKlass {
package var one: Int = 1
package var two: String = ""
package func f() {}
}
@_fixed_layout // expected-error {{'@_fixed_layout' attribute can only be applied to '@usableFromInline', package, or public declarations, but 'FixedInternalKlass' is internal}} {{1-16=}}
class FixedInternalKlass {
var one: Int = 1
var two: String = ""
func f() {}
}