Files
swift-mirror/test/SILGen/enum_witness_thunks.swift
Joe Groff 4becd80fff SIL: Pick default ARC convention for witness thunks based on the kind of the original decl.
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.
2021-02-08 15:24:10 -08:00

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]]