mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SIL type lowering erases DynamicSelfType, so we generate incorrect code when casting to DynamicSelfType. Fixing this requires a fair amount of plumbing, but most of the changes are mechanical. Note that the textual SIL syntax for casts has changed slightly; the target type is now a formal type without a '$', not a SIL type. Also, the unconditional_checked_cast_value and checked_cast_value_br instructions now take the _source_ formal type as well, just like the *_addr forms they are intended to replace.
37 lines
921 B
Swift
37 lines
921 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -emit-ir -wmo -O %s > %t/out.txt
|
|
// RUN: %FileCheck %s < %t/out.txt
|
|
// RUN: %FileCheck %s --check-prefix=NEGATIVE < %t/out.txt
|
|
|
|
// Both should be emitted:
|
|
|
|
// CHECK: @"$s19lazy_field_metadata011GenericWithD5FieldVMn" = hidden constant
|
|
// CHECK: @"$s19lazy_field_metadata24GenericWithConcreteFieldVMn" = hidden constant
|
|
|
|
struct GenericWithConcreteField<T> {
|
|
let z = 123
|
|
}
|
|
|
|
struct GenericWithGenericField<T> {
|
|
var field = GenericWithConcreteField<T>()
|
|
}
|
|
|
|
@_optimize(none)
|
|
public func takeMetadata<T>(_: T.Type) {}
|
|
|
|
public func forceMetadata() {
|
|
takeMetadata(GenericWithGenericField<Int>.self)
|
|
}
|
|
|
|
// These two types are completely unused.
|
|
struct TypeOfProperty {
|
|
var x: Int
|
|
}
|
|
|
|
struct HasPropertyType {
|
|
var p: TypeOfProperty
|
|
}
|
|
|
|
// NEGATIVE-NOT: @"$s19lazy_field_metadata14TypeOfPropertyVMn"
|
|
// NEGATIVE-NOT: @"$s19lazy_field_metadata15HasPropertyTypeVMn"
|