Skip to content

Commit 2ce5a33

Browse files
authored
Merge pull request #73915 from hamishknight/fix-emitCallToUnmappedExplosion-crash
2 parents 6559ed6 + cfdf35f commit 2ce5a33

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,10 +2615,13 @@ class SyncCallEmission final : public CallEmission {
26152615
== ResultConvention::Autoreleased)) {
26162616
if (IGF.IGM.Context.LangOpts.EnableObjCInterop) {
26172617
auto ty = fnConv.getSILResultType(IGF.IGM.getMaximalTypeExpansionContext());
2618-
auto *classTypeInfo = dyn_cast<ClassTypeInfo>(&IGF.IGM.getTypeInfo(ty));
2619-
if (classTypeInfo && classTypeInfo->getReferenceCounting() == ReferenceCounting::Custom) {
2618+
// NOTE: We cannot dyn_cast directly to ClassTypeInfo since it does not
2619+
// implement 'classof', so will succeed for any ReferenceTypeInfo.
2620+
auto *refTypeInfo = dyn_cast<ReferenceTypeInfo>(&IGF.IGM.getTypeInfo(ty));
2621+
if (refTypeInfo &&
2622+
refTypeInfo->getReferenceCountingType() == ReferenceCounting::Custom) {
26202623
Explosion e(result);
2621-
classTypeInfo->strongCustomRetain(IGF, e, true);
2624+
refTypeInfo->as<ClassTypeInfo>().strongCustomRetain(IGF, e, true);
26222625
} else {
26232626
result = emitObjCRetainAutoreleasedReturnValue(IGF, result);
26242627
}

0 commit comments

Comments
 (0)