mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Enum constructors take their arguments +1 by default, but they can now be used to satisfy protocol static member requirements, which take arguments +0 by default. Type lowering would accidentally use the kind of the witness to determine the conventions for the witness thunk, leading to a miscompile when the requirement is called through the protocol. Fixes rdar://74117738.
16 lines
379 B
Swift
16 lines
379 B
Swift
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
|
|
|
|
class C {}
|
|
|
|
protocol P {
|
|
static func c(_: C) -> Self
|
|
}
|
|
|
|
enum E: P {
|
|
case c(C)
|
|
}
|
|
|
|
// CHECK-LABEL: sil {{.*}} @$s19enum_witness_thunks1EOAA1PA2aDP1cyxAA1CCFZTW : $@convention(witness_method: P) (@guaranteed C, @thick E.Type) -> @out E
|
|
// CHECK: [[COPY:%.*]] = copy_value
|
|
// CHECK: apply {{.*}}([[COPY]]
|