mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We need the self metatype parameter to correctly lower DynamicSelfType in IRGen, so plumb this through to all calls of init accessors, and inside the prolog of an init accessor definition. This does not break the public ABI, because init accessors are never public. Also for value types, the metatype is thin, so it should not change generated code. For classes we need the metatype in the general case because of `Self`, but hopefully in most cases the init accessor can be inlined away and the value_metatype instruction subject to dead code elimination. Fixes rdar://problem/119822466.
22 lines
312 B
Swift
22 lines
312 B
Swift
// RUN: %target-swift-frontend -emit-ir %s
|
|
|
|
public class C {
|
|
private var _count: Int
|
|
|
|
var count: Int {
|
|
@storageRestrictions(initializes: _count)
|
|
init {
|
|
print(Self.self) // crash here
|
|
_count = newValue
|
|
}
|
|
get { _count }
|
|
set { }
|
|
}
|
|
|
|
init() {
|
|
count = 0
|
|
}
|
|
}
|
|
|
|
let c = C()
|