Skip to content

Commit 5c23950

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents c0098f9 + bdb52b3 commit 5c23950

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

lib/IRGen/Outlining.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ void OutliningMetadataCollector::collectTypeMetadataForLayout(SILType type) {
3636
}
3737

3838
// Substitute opaque types if allowed.
39+
auto origType = type;
3940
type = IGF.IGM.substOpaqueTypesWithUnderlyingTypes(type);
4041

4142
auto formalType = type.getASTType();
@@ -44,7 +45,9 @@ void OutliningMetadataCollector::collectTypeMetadataForLayout(SILType type) {
4445
// We don't need the metadata for fixed size types or types that are not ABI
4546
// accessible. Outlining will call the value witness of the enclosing type of
4647
// non ABI accessible field/element types.
47-
if (isa<FixedTypeInfo>(ti) || !ti.isABIAccessible()) {
48+
if ((!origType.getASTType()->hasOpaqueArchetype() &&
49+
isa<FixedTypeInfo>(ti)) ||
50+
!ti.isABIAccessible()) {
4851
return;
4952
}
5053

test/IRGen/opaque_result_type_substitution.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,43 @@ public func usePair<T, V>(_ t: T, _ v: V) {
2424
print(p)
2525
}
2626

27+
protocol P { }
28+
29+
struct C<S : Hashable> {
30+
struct Inner {}
31+
32+
init(_ s: S) { }
33+
34+
func getInner() -> Inner {
35+
return Inner()
36+
}
37+
}
38+
39+
struct O<T> {
40+
var t: T
41+
42+
init(_ t: T) {
43+
self.t = t
44+
}
45+
}
46+
47+
struct M<T, V> : P {
48+
init(_ f: T, _ s: V) {
49+
}
50+
51+
func foobar() -> some P {
52+
return self
53+
}
54+
}
55+
56+
public func test2<S : Hashable, T, V>(_ s: S, _ t: T, _ v: V) {
57+
var x = M(C(s).getInner(), t)
58+
let q = x.foobar()
59+
let u = x.foobar()
60+
let y = O(q)
61+
print(y)
62+
}
63+
2764
// CHECK-LABEL: define{{.*}} swiftcc void @"$s31opaque_result_type_substitution7usePairyyx_q_tr0_lF"({{.*}}, %swift.type* %T, %swift.type* %V)
2865
// CHECK: [[PAIR_TV:%.*]] = call swiftcc %swift.metadata_response @"$s31opaque_result_type_substitution4PairVMa"({{.*}}, %swift.type* %T, %swift.type* %V)
2966
// CHECK: [[MD:%.*]] = extractvalue %swift.metadata_response [[PAIR_TV]], 0

0 commit comments

Comments
 (0)