Skip to content

Commit cd8c46f

Browse files
authored
Merge pull request #77076 from drexin/wip-137954177-6.0
[6.0][IRGen] Don't try to emit single payload CVW for incompatible multi p…
2 parents f30a16c + 9ae1aeb commit cd8c46f

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

lib/IRGen/TypeLayout.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,8 @@ bool EnumTypeLayoutEntry::refCountString(IRGenModule &IGM,
24062406
if (isMultiPayloadEnum() &&
24072407
buildMultiPayloadRefCountString(IGM, B, genericSig)) {
24082408
return true;
2409-
} else if (buildSinglePayloadRefCountString(IGM, B, genericSig)) {
2409+
} else if (!isMultiPayloadEnum() &&
2410+
buildSinglePayloadRefCountString(IGM, B, genericSig)) {
24102411
return true;
24112412
}
24122413

test/Interpreter/layout_string_witnesses_objc.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,45 @@ func testNestedResilientObjc() {
4848
}
4949

5050
testNestedResilientObjc()
51+
52+
protocol P {}
53+
54+
extension ObjCPrintOnDealloc: P {}
55+
56+
enum MultiPayloadObjCExistential {
57+
case x(AnyObject)
58+
case y(P & ObjCPrintOnDealloc)
59+
}
60+
61+
struct MultiPayloadObjCExistentialWrapper {
62+
let x: MultiPayloadObjCExistential
63+
let y: Int = 0
64+
}
65+
66+
func testMultiPayloadObjCExistentialWrapper() {
67+
let ptr = allocateInternalGenericPtr(of: NestedWrapper<MultiPayloadObjCExistentialWrapper>.self)
68+
69+
do {
70+
let x = MultiPayloadObjCExistentialWrapper(x: .y(ObjCPrintOnDealloc()))
71+
testGenericInit(ptr, to: x)
72+
}
73+
74+
do {
75+
let y = MultiPayloadObjCExistentialWrapper(x: .y(ObjCPrintOnDealloc()))
76+
// CHECK: Before deinit
77+
print("Before deinit")
78+
79+
// CHECK-NEXT: ObjCPrintOnDealloc deinitialized!
80+
testGenericAssign(ptr, from: y)
81+
}
82+
83+
// CHECK-NEXT: Before deinit
84+
print("Before deinit")
85+
86+
// CHECK-NEXT: ObjCPrintOnDealloc deinitialized!
87+
testGenericDestroy(ptr, of: NestedWrapper<MultiPayloadObjCExistentialWrapper>.self)
88+
89+
ptr.deallocate()
90+
}
91+
92+
testMultiPayloadObjCExistentialWrapper()

0 commit comments

Comments
 (0)