Skip to content

Commit 1599d3e

Browse files
committed
Pass subst options down when substitution sil_box type's substitution map
rdar://70262551
1 parent 38c8bbd commit 1599d3e

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

lib/AST/Type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3759,7 +3759,7 @@ static Type substType(Type derivedType,
37593759
// we want to structurally substitute the substitutions.
37603760
if (auto boxTy = dyn_cast<SILBoxType>(type)) {
37613761
auto subMap = boxTy->getSubstitutions();
3762-
auto newSubMap = subMap.subst(substitutions, lookupConformances);
3762+
auto newSubMap = subMap.subst(substitutions, lookupConformances, options);
37633763

37643764
return SILBoxType::get(boxTy->getASTContext(),
37653765
boxTy->getLayout(),
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public protocol Butt {}
2+
extension Int: Butt {}
3+
4+
public func exportsOpaqueReturn() -> some Butt { return 0 }
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -disable-availability-checking -primary-file %S/Inputs/specialize_opaque_result_types.swift -enable-library-evolution -module-name A -emit-sib -o %t/A.sib
3+
// RUN: %target-swift-frontend -emit-sil -primary-file %s -enable-library-evolution -O -module-name A %t/A.sib -o - | %FileCheck %s
4+
5+
sil_stage canonical
6+
7+
import Builtin
8+
import Swift
9+
import SwiftShims
10+
11+
typealias SomeButt = @_opaqueReturnTypeOf("$s1A19exportsOpaqueReturnQryF", 0) opaque
12+
13+
sil @$foobar : $@convention(thin) () -> @out SomeButt {
14+
bb0(%0 : $*Int):
15+
%1 = integer_literal $Builtin.Int64, 0 // user: %2
16+
%2 = struct $Int (%1 : $Builtin.Int64) // user: %3
17+
store %2 to %0 : $*Int // id: %3
18+
%4 = tuple () // user: %5
19+
return %4 : $() // id: %5
20+
}
21+
22+
sil @getGenericClosure_closure : $@convention(thin) <T> (@owned <τ_0_0> { var τ_0_0 } <T>) -> @out T
23+
24+
sil [noinline] @getGenericClosure : $@convention(thin) <T> (@in T) -> @owned @callee_owned () -> @out T {
25+
bb0(%0 : $*T):
26+
debug_value_addr %0 : $*T, let, name "t" // id: %1
27+
%2 = function_ref @getGenericClosure_closure : $@convention(thin) <τ_0_0> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0 // user: %5
28+
%3 = alloc_box $<τ_0_0> { var τ_0_0 } <T> // users: %4, %5, %5
29+
%3a = project_box %3 : $<τ_0_0> { var τ_0_0 } <T>, 0
30+
copy_addr %0 to [initialization] %3a : $*T // id: %4
31+
%5 = partial_apply %2<T>(%3) : $@convention(thin) <τ_0_0> (@owned <τ_0_0> { var τ_0_0 } <τ_0_0>) -> @out τ_0_0 // user: %7
32+
destroy_addr %0 : $*T // id: %6
33+
return %5 : $@callee_owned () -> @out T // id: %7
34+
}
35+
36+
// CHECK-LABEL: sil shared [noinline] @$s17getGenericClosure1A19exportsOpaqueReturnQryFQOyQo__Tg5 : $@convention(thin) (Int) -> @owned @callee_owned () -> @out Int {
37+
// CHECK: alloc_box $<τ_0_0> { var τ_0_0 } <Int>
38+
// CHECK: } // end sil function '$s17getGenericClosure1A19exportsOpaqueReturnQryFQOyQo__Tg5'
39+
40+
sil [transparent] [serialized] @specializePartialApplies : $@convention(thin) (@in SomeButt) -> () {
41+
bb0(%0 : $*SomeButt):
42+
%5 = function_ref @getGenericClosure : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @owned @callee_owned () -> @out τ_0_0
43+
%8 = apply %5<SomeButt>(%0) : $@convention(thin) <τ_0_0> (@in τ_0_0) -> @owned @callee_owned () -> @out τ_0_0
44+
%15 = tuple()
45+
return %15 : $()
46+
}

0 commit comments

Comments
 (0)