mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
IRGen: Workaround for inadvertent mangling of opened archetypes
This commit is contained in:
@@ -1528,6 +1528,19 @@ public:
|
||||
boxedInterfaceType = boxedType.mapTypeOutOfContext();
|
||||
}
|
||||
|
||||
{
|
||||
// FIXME: This seems wrong. We used to just mangle opened archetypes as
|
||||
// their interface type. Let's make that explicit now.
|
||||
auto astType = boxedInterfaceType.getASTType();
|
||||
astType = astType.transformRec([](Type t) -> Optional<Type> {
|
||||
if (auto *openedExistential = t->getAs<OpenedArchetypeType>())
|
||||
return openedExistential->getInterfaceType();
|
||||
return None;
|
||||
})->getCanonicalType();
|
||||
boxedInterfaceType = SILType::getPrimitiveType(
|
||||
astType, boxedInterfaceType.getCategory());
|
||||
}
|
||||
|
||||
auto boxDescriptor = IGF.IGM.getAddrOfBoxDescriptor(
|
||||
boxedInterfaceType,
|
||||
env ? env->getGenericSignature().getCanonicalSignature()
|
||||
|
||||
18
test/Reflection/box_descriptor_with_opened_archetype.swift
Normal file
18
test/Reflection/box_descriptor_with_opened_archetype.swift
Normal file
@@ -0,0 +1,18 @@
|
||||
// RUN: %target-swift-frontend -emit-ir %s -disable-availability-checking
|
||||
|
||||
public protocol P {}
|
||||
|
||||
struct S<T>: P {
|
||||
var x: Any
|
||||
init() { fatalError() }
|
||||
}
|
||||
|
||||
public func mangleArchetype(_ p: any P) -> any P {
|
||||
p.open
|
||||
}
|
||||
|
||||
extension P {
|
||||
var open: some P {
|
||||
S<Self>()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user