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.
39 lines
991 B
Swift
39 lines
991 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -parse-as-library -module-name=test -O %s -emit-ir -disable-reflection-metadata > %t/out.txt
|
|
// RUN: %FileCheck %s < %t/out.txt
|
|
// RUN: %FileCheck %s --check-prefix=NEGATIVE < %t/out.txt
|
|
|
|
// We have an unused conformance. It should not crash.
|
|
//
|
|
// FIXME: Actually stop emitting the conformance.
|
|
struct S { }
|
|
|
|
extension S: Equatable {
|
|
static func ==(lhs: S, rhs: S) -> Bool {
|
|
return false
|
|
}
|
|
}
|
|
|
|
// We should only emit metadata for the second type, even though it has a
|
|
// field whose type is the first.
|
|
struct TypeOfProperty {
|
|
var x: Int
|
|
}
|
|
|
|
struct HasPropertyType {
|
|
var p: TypeOfProperty
|
|
}
|
|
|
|
// NEGATIVE-NOT: @"$s4test14TypeOfPropertyVMn"
|
|
// CHECK-LABEL: @"$s4test15HasPropertyTypeVMn"
|
|
|
|
@_optimize(none)
|
|
public func takeMetadata<T>(_: T.Type) {}
|
|
|
|
public func forceMetadata() {
|
|
takeMetadata(HasPropertyType.self)
|
|
}
|
|
|
|
// CHECK-LABEL: @"$s4test1SVMn" = hidden constant
|
|
// CHECK-LABEL: @"$s4test1SVSQAAMc" = hidden constant
|