Skip to content

Commit e955c63

Browse files
authored
Merge pull request swiftlang#68630 from slavapestov/fix-rdar115355709
SIL: Fix opaque type erasure after clearing [serialized] flags
2 parents a119aaf + ce3b2a4 commit e955c63

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

lib/SILOptimizer/UtilityPasses/SerializeSILPass.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ class MapOpaqueArchetypes : public SILCloner<MapOpaqueArchetypes> {
5757
.getTypeExpansionContext()
5858
.shouldLookThroughOpaqueTypeArchetypes())
5959
return ty;
60-
// Remap types containing opaque result types in the current context.
61-
return getBuilder()
62-
.getTypeLowering(SILType::getPrimitiveObjectType(ty))
63-
.getLoweredType()
64-
.getASTType();
60+
61+
return substOpaqueTypesWithUnderlyingTypes(
62+
ty,
63+
TypeExpansionContext(getBuilder().getFunction()),
64+
/*allowLoweredTypes=*/false);
6565
}
6666

6767
ProtocolConformanceRef remapConformance(Type ty,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module %s -disable-availability-checking
3+
4+
// We substitute away opaque archetypes after serialization;
5+
// make sure this correctly handles unlowered types like
6+
// AST functions and packs.
7+
8+
public func horse<T>(_: T) {}
9+
10+
@_transparent public func packCallee<each T>(_ t: repeat each T) {
11+
repeat horse(each t)
12+
}
13+
14+
@inlinable public func packCaller() {
15+
packCallee(opaque())
16+
}
17+
18+
public func opaque() -> some Any { return 3 }

0 commit comments

Comments
 (0)