Skip to content

Commit 6c1a2fd

Browse files
authored
Merge pull request swiftlang#83899 from slavapestov/fix-issue83539
IRGen: Fix crash trying to emit capture descriptor involving element archetype
2 parents 45069a1 + 831043c commit 6c1a2fd

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

lib/IRGen/GenHeap.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,24 +1576,6 @@ class FixedBoxTypeInfoBase : public BoxTypeInfo {
15761576
boxedInterfaceType = boxedType.mapTypeOutOfContext();
15771577
}
15781578

1579-
{
1580-
// FIXME: This seems wrong. We used to just mangle opened archetypes as
1581-
// their interface type. Let's make that explicit now.
1582-
auto astType = boxedInterfaceType.getASTType();
1583-
astType =
1584-
astType
1585-
.transformRec([](Type t) -> std::optional<Type> {
1586-
if (auto *openedExistential = t->getAs<ExistentialArchetypeType>()) {
1587-
auto &ctx = openedExistential->getASTContext();
1588-
return ctx.TheSelfType;
1589-
}
1590-
return std::nullopt;
1591-
})
1592-
->getCanonicalType();
1593-
boxedInterfaceType = SILType::getPrimitiveType(
1594-
astType, boxedInterfaceType.getCategory());
1595-
}
1596-
15971579
auto boxDescriptor = IGF.IGM.getAddrOfBoxDescriptor(
15981580
boxedInterfaceType,
15991581
env ? env->getGenericSignature().getCanonicalSignature()

lib/IRGen/GenReflection.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,6 +1693,9 @@ llvm::Constant *IRGenModule::getAddrOfFieldName(StringRef Name) {
16931693
llvm::Constant *
16941694
IRGenModule::getAddrOfBoxDescriptor(SILType BoxedType,
16951695
CanGenericSignature genericSig) {
1696+
if (BoxedType.hasLocalArchetype())
1697+
return llvm::Constant::getNullValue(CaptureDescriptorPtrTy);
1698+
16961699
if (IRGen.Opts.ReflectionMetadata != ReflectionMetadataMode::Runtime)
16971700
return llvm::Constant::getNullValue(CaptureDescriptorPtrTy);
16981701

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -target %target-swift-5.9-abi-triple
2+
3+
public protocol P {}
4+
5+
public struct G<T>: P {
6+
let s1: String
7+
let s2: String
8+
}
9+
10+
public func f<each T>(t: repeat G<each T>) {
11+
var ts: [any P] = []
12+
for x in repeat each t {
13+
ts.append(x)
14+
}
15+
}

0 commit comments

Comments
 (0)