Skip to content

Commit 4722e1e

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents e1838a3 + 5722762 commit 4722e1e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

lib/IRGen/Outlining.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ void OutliningMetadataCollector::collectTypeMetadataForLayout(SILType type) {
3535
return;
3636
}
3737

38+
// Substitute opaque types if allowed.
39+
type = IGF.IGM.substOpaqueTypesWithUnderlyingTypes(type);
40+
3841
auto formalType = type.getASTType();
3942
auto &ti = IGF.IGM.getTypeInfoForLowered(formalType);
4043

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %target-swift-frontend -disable-availability-checking -emit-ir %s | %FileCheck %s
2+
3+
protocol E {}
4+
5+
struct Pair<T, V> : E {
6+
var fst : T
7+
var snd : V
8+
9+
init(_ f: T, _ s: V) {
10+
self.fst = f
11+
self.snd = s
12+
}
13+
14+
func foobar() -> some E {
15+
return self
16+
}
17+
}
18+
19+
public func usePair<T, V>(_ t: T, _ v: V) {
20+
var x = Pair(t, v)
21+
let q = x.foobar()
22+
let u = x.foobar()
23+
let p = Pair(q, u)
24+
print(p)
25+
}
26+
27+
// CHECK-LABEL: define{{.*}} swiftcc void @"$s31opaque_result_type_substitution7usePairyyx_q_tr0_lF"({{.*}}, %swift.type* %T, %swift.type* %V)
28+
// CHECK: [[PAIR_TV:%.*]] = call swiftcc %swift.metadata_response @"$s31opaque_result_type_substitution4PairVMa"({{.*}}, %swift.type* %T, %swift.type* %V)
29+
// CHECK: [[MD:%.*]] = extractvalue %swift.metadata_response [[PAIR_TV]], 0
30+
// CHECK: [[PAIR_OPAQUE:%.*]] = call swiftcc %swift.metadata_response @"$s31opaque_result_type_substitution4PairVMa"({{.*}}, %swift.type* [[MD]], %swift.type* [[MD]])
31+
// CHECK: [[MD2:%.*]] = extractvalue %swift.metadata_response [[PAIR_OPAQUE]], 0
32+
// CHECK: call {{.*}}* @"$s31opaque_result_type_substitution4PairVyAC6foobarQryFQOyxq__Qo_AEGr0_lWOh"({{.*}}, %swift.type* {{.*}}, %swift.type* [[MD2]])

0 commit comments

Comments
 (0)