Skip to content

Commit aa8a07a

Browse files
authored
Merge pull request swiftlang#31347 from jckarter/opaque-structural-type-reabstraction
SILGen: Fix some issues with tuple/metatype/function reabstraction against opaque return types.
2 parents cf92823 + 65a2f92 commit aa8a07a

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lib/SIL/IR/AbstractionPattern.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ AbstractionPattern::getTupleElementType(unsigned index) const {
378378
case Kind::Discard:
379379
llvm_unreachable("operation not needed on discarded abstractions yet");
380380
case Kind::Type:
381-
if (isTypeParameter())
381+
if (isTypeParameterOrOpaqueArchetype())
382382
return AbstractionPattern::getOpaque();
383383
return AbstractionPattern(getGenericSignature(),
384384
getCanTupleElementType(getType(), index));

lib/SIL/IR/TypeLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ TypeConverter::computeLoweredRValueType(TypeExpansionContext forExpansion,
18211821
auto origMeta = origType.getAs<MetatypeType>();
18221822
if (!origMeta) {
18231823
// If the metatype matches a dependent type, it must be thick.
1824-
assert(origType.isTypeParameter());
1824+
assert(origType.isTypeParameterOrOpaqueArchetype());
18251825
repr = MetatypeRepresentation::Thick;
18261826
} else {
18271827
// Otherwise, we're thin if the metatype is thinnable both
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-emit-silgen -disable-availability-checking %s | %FileCheck %s
2+
3+
// CHECK-LABEL: sil {{.*}}9withTuple
4+
// CHECK: bb0(%0 : $*(Int, String)):
5+
func withTuple() -> some Any {
6+
return (1, "hello")
7+
}
8+
9+
struct S {}
10+
11+
// CHECK-LABEL: sil {{.*}}12withMetatype
12+
// CHECK: bb0(%0 : $*@thick S.Type):
13+
func withMetatype() -> some Any {
14+
return S.self
15+
}
16+
17+
// CHECK-LABEL: sil {{.*}}12withFunction
18+
// CHECK: bb0(%0 : $*@callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>):
19+
func withFunction() -> some Any {
20+
let f: () -> () = {}
21+
return f
22+
}
23+
24+
// CHECK-LABEL: sil {{.*}}30withTupleOfMetatypeAndFunction
25+
// CHECK: bb0(%0 : $*(@thick S.Type, @callee_guaranteed @substituted <τ_0_0> () -> @out τ_0_0 for <()>)):
26+
func withTupleOfMetatypeAndFunction() -> some Any {
27+
let f: () -> () = {}
28+
return (S.self, f)
29+
}

0 commit comments

Comments
 (0)