Skip to content

Commit ad86290

Browse files
authored
Merge pull request swiftlang#35838 from jckarter/enum-case-witness-default-conventions
SIL: Pick default ARC convention for witness thunks based on the kind of the original decl.
2 parents e162ea6 + 4becd80 commit ad86290

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ static CanSILFunctionType getNativeSILFunctionType(
24862486
case SILFunctionType::Representation::Method:
24872487
case SILFunctionType::Representation::Closure:
24882488
case SILFunctionType::Representation::WitnessMethod: {
2489-
switch (constant ? constant->kind : SILDeclRef::Kind::Func) {
2489+
switch (origConstant ? origConstant->kind : SILDeclRef::Kind::Func) {
24902490
case SILDeclRef::Kind::Initializer:
24912491
case SILDeclRef::Kind::EnumElement:
24922492
return getSILFunctionTypeForConventions(DefaultInitializerConventions());

test/SILGen/enum_witness_thunks.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
2+
3+
class C {}
4+
5+
protocol P {
6+
static func c(_: C) -> Self
7+
}
8+
9+
enum E: P {
10+
case c(C)
11+
}
12+
13+
// CHECK-LABEL: sil {{.*}} @$s19enum_witness_thunks1EOAA1PA2aDP1cyxAA1CCFZTW : $@convention(witness_method: P) (@guaranteed C, @thick E.Type) -> @out E
14+
// CHECK: [[COPY:%.*]] = copy_value
15+
// CHECK: apply {{.*}}([[COPY]]

0 commit comments

Comments
 (0)