AST: Static properties of fixed-layout types are resilient

We don't want @_fixed_layout to apply to static properties, or you
get fun consequences like not being able to change static stored
properties defined in extensions of imported types to computed.
This commit is contained in:
Slava Pestov
2018-01-20 21:22:58 -08:00
parent 834a121b10
commit 8f9f7afc55
7 changed files with 117 additions and 21 deletions

View File

@@ -48,3 +48,24 @@ private let privateGlobal = 0
struct AnotherInternalStruct {
var storedProperty = privateGlobal
}
// Static properties in fixed-layout type is still resilient
@_fixed_layout
public struct HasStaticProperty {
public static var staticProperty: Int = 0
}
// CHECK-LABEL: sil @$S22fixed_layout_attribute18usesStaticPropertyyyF : $@convention(thin) () -> ()
// CHECK: function_ref @$S22fixed_layout_attribute17HasStaticPropertyV06staticF0Sivau : $@convention(thin) () -> Builtin.RawPointer
// CHECK: return
public func usesStaticProperty() {
_ = HasStaticProperty.staticProperty
}
// CHECK-LABEL: sil [serialized] @$S22fixed_layout_attribute28usesStaticPropertyInlineableyyF : $@convention(thin) () -> ()
@_inlineable
public func usesStaticPropertyInlineable() {
_ = HasStaticProperty.staticProperty
}