Files
swift-mirror/test/IRGen/lazy_field_metadata.swift
Slava Pestov 53bfc767a3 SIL: Track target formal type for casts
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.
2019-11-20 21:30:28 -05:00

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"