|
1 |
| -// RUN: %target-swift-frontend -use-native-super-method -emit-silgen %s | FileCheck %s |
| 1 | +// RUN: rm -rf %t |
| 2 | +// RUN: mkdir %t |
| 3 | +// RUN: %target-swift-frontend -emit-module -module-name OutsideClasses -o %t %S/../Inputs/outside_classes_before.swift |
| 4 | +// RUN: %target-swift-frontend -use-native-super-method -emit-silgen -I %t %S/../Inputs/partial_apply_super.swift | FileCheck %s --check-prefix=SILGEN |
2 | 5 |
|
3 |
| -func doFoo(f: () -> ()) { |
4 |
| - f() |
5 |
| -} |
| 6 | +// Child.method |
| 7 | +// SILGEN-LABEL: sil hidden @_TFC19partial_apply_super5Child6methodfT_T_ |
| 8 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ |
| 9 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $Child to $Parent |
| 10 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method %0 : $Child, #Parent.method!1 |
| 11 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]([[CASTED_SELF]]) |
| 12 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) |
6 | 13 |
|
7 |
| -class Base { |
8 |
| - func method() { } |
9 |
| - func bar()() { } |
10 |
| - class func classMethod() {} |
11 |
| -} |
| 14 | +// Child.classMethod |
| 15 | +// SILGEN-LABEL: sil hidden @_TZFC19partial_apply_super5Child11classMethodfT_T_ : $@convention(thin) (@thick Child.Type) -> () { |
| 16 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () // user: %6 |
| 17 | +// SILGEN-NEXT: [[CASTED_SELF:%[0-9]+]] = upcast %0 : $@thick Child.Type to $@thick Parent.Type // user: %5 |
| 18 | +// SILGEN-NEXT: [[SUPER_METHOD:%[0-9]+]] = super_method %0 : $@thick Child.Type, #Parent.classMethod!1 : Parent.Type -> () -> () , $@convention(thin) (@thick Parent.Type) -> () |
| 19 | +// SILGEN-NEXT: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]([[CASTED_SELF]]) : $@convention(thin) (@thick Parent.Type) -> () |
| 20 | +// SILGEN-NEXT: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
12 | 21 |
|
13 |
| -class Derived : Base { |
14 |
| - // CHECK-LABEL: sil hidden @_TFC19partial_apply_super7Derived6methodfT_T_ |
15 |
| - // CHECK: [[DOFOO:%[0-9]+]] = function_ref @_TF19partial_apply_super5doFooFFT_T_T_ |
16 |
| - // CHECK: [[CASTED_SELF:%[0-9]+]] = upcast %0 : $Derived to $Base |
17 |
| - // CHECK: [[SUPER_METHOD:%[0-9]+]] = super_method %0 : $Derived, #Base.method!1 |
18 |
| - // CHECK: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]([[CASTED_SELF]]) |
19 |
| - // CHECK: apply [[DOFOO]]([[PARTIAL_APPLY]]) |
20 |
| - override func method() { |
21 |
| - doFoo(super.method) |
22 |
| - } |
| 22 | +// GenericChild.method |
| 23 | +// SILGEN-LABEL: sil hidden @_TFC19partial_apply_super12GenericChild6methodfT_T_ : $@convention(method) <A> (@guaranteed GenericChild<A>) -> () |
| 24 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
| 25 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $GenericChild<A> to $GenericParent<A> |
| 26 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method {{%[0-9]+}} : $GenericChild<A>, #GenericParent.method!1 : <A> GenericParent<A> -> () -> () , $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> () |
| 27 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]<A>([[CASTED_SELF]]) : $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> () |
| 28 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
23 | 29 |
|
24 |
| - // CHECK-LABEL: sil hidden @_TZFC19partial_apply_super7Derived11classMethodfT_T_ |
25 |
| - // CHECK: [[DOFOO:%[0-9]+]] = function_ref @_TF19partial_apply_super5doFooFFT_T_T_ |
26 |
| - // CHECK: [[CASTED_SELF:%[0-9]+]] = upcast %0 : $@thick Derived.Type to $@thick Base.Type |
27 |
| - // CHECK: [[SUPER_METHOD:%[0-9]+]] = super_method %0 : $@thick Derived.Type, #Base.classMethod!1 |
28 |
| - // CHECK: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply %4(%3) : $@convention(thin) (@thick Base.Type) -> () |
29 |
| - override class func classMethod() { |
30 |
| - doFoo(super.classMethod) |
31 |
| - } |
| 30 | +// GenericChild.classMethod |
| 31 | +// SILGEN-LABEL: sil hidden @_TZFC19partial_apply_super12GenericChild11classMethodfT_T_ : $@convention(thin) <A> (@thick GenericChild<A>.Type) -> () |
| 32 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
| 33 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $@thick GenericChild<A>.Type to $@thick GenericParent<A>.Type |
| 34 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method {{%[0-9]}} : $@thick GenericChild<A>.Type, #GenericParent.classMethod!1 : <A> GenericParent<A>.Type -> () -> () , $@convention(thin) <τ_0_0> (@thick GenericParent<τ_0_0>.Type) -> () |
| 35 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]<A>([[CASTED_SELF]]) : $@convention(thin) <τ_0_0> (@thick GenericParent<τ_0_0>.Type) -> () |
| 36 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
32 | 37 |
|
33 |
| - // CHECK-LABEL: sil hidden @_TFC19partial_apply_super7Derived10getMethodsfT_TFT_T_FT_T__ |
34 |
| - // CHECK: function_ref @_TFC19partial_apply_super7Derived6method |
35 |
| - // CHECK: super_method %0 : $Derived, #Base.method!1 : Base -> () -> () |
36 |
| - func getMethods() -> (() -> (), () -> ()) { |
37 |
| - return (self.method, super.method) |
38 |
| - } |
| 38 | +// closure.Child.method |
| 39 | +// SILGEN-LABEL: sil shared @_TFCF19partial_apply_superU_FT_T_L_5Child6methodfT_T_ : $@convention(method) (@guaranteed Child) -> () |
| 40 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () // user: %7 |
| 41 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $Child to $Parent |
| 42 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method {{%[0-9]+}} : $Child, #Parent.method!1 : Parent -> () -> () , $@convention(method) (@guaranteed Parent) -> () |
| 43 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]([[CASTED_SELF]]) : $@convention(method) (@guaranteed Parent) -> () |
| 44 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
39 | 45 |
|
40 |
| - // CHECK-LABEL: sil shared @_TFC19partial_apply_super7Derived6methodFT_T_ |
41 |
| - // CHECK: class_method %0 : $Derived, #Derived.method!1 |
| 46 | +// closure.Child.classMethod |
| 47 | +// SILGEN-LABEL: sil shared @_TZFCF19partial_apply_superU_FT_T_L_5Child11classMethodfT_T_ : $@convention(thin) (@thick Child.Type) -> () { |
| 48 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () // user: %6 |
| 49 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $@thick Child.Type to $@thick Parent.Type // user: %5 |
| 50 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method {{%[0-9]+}} : $@thick Child.Type, #Parent.classMethod!1 : Parent.Type -> () -> () , $@convention(thin) (@thick Parent.Type) -> () // user: %5 |
| 51 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]([[CASTED_SELF]]) : $@convention(thin) (@thick Parent.Type) -> () // user: %6 |
| 52 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
42 | 53 |
|
43 |
| - // CHECK-LABEL: sil hidden @_TFC19partial_apply_super7Derived6getBar |
44 |
| - // CHECK: function_ref @_TFC19partial_apply_super4Base3barFT_FT_T_ |
45 |
| - func getBar() -> (() -> () -> ()) { |
46 |
| - return self.bar |
47 |
| - } |
48 |
| -} |
| 54 | +// closure.GenericChild.method |
| 55 | +// SILGEN-LABEL: sil shared @_TFCF19partial_apply_superU0_FT_T_L_12GenericChild6methodfT_T_ : $@convention(method) <A> (@guaranteed GenericChild<A>) -> () |
| 56 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
| 57 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $GenericChild<A> to $GenericParent<A> |
| 58 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method {{%[0-9]+}} : $GenericChild<A>, #GenericParent.method!1 : <A> GenericParent<A> -> () -> () , $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> () |
| 59 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]<A>([[CASTED_SELF]]) : $@convention(method) <τ_0_0> (@guaranteed GenericParent<τ_0_0>) -> () |
| 60 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
49 | 61 |
|
50 |
| -// Test partial application of super with local types |
51 |
| -let c = { |
52 |
| - class Base { |
53 |
| - func method() {} |
54 |
| - class func classMethod() {} |
55 |
| - } |
56 |
| - class Derived : Base { |
57 |
| - // CHECK-LABEL: sil shared @_TFCF19partial_apply_superU_FT_T_L_7Derived6methodfT_T_ |
58 |
| - // CHECK: [[DOFOO:%[0-9]+]] = function_ref @_TF19partial_apply_super5doFooFFT_T_T_ |
59 |
| - // CHECK: [[CASTED_SELF:%[0-9]+]] = upcast %0 : $Derived to $Base |
60 |
| - // CHECK: [[SUPER_METHOD:%[0-9]+]] = super_method %0 : $Derived, #<anonymous function>Base.method!1 |
61 |
| - // CHECK: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]([[CASTED_SELF]]) |
62 |
| - // CHECK: apply [[DOFOO]]([[PARTIAL_APPLY]]) |
63 |
| - override func method() { |
64 |
| - doFoo(super.method) |
65 |
| - } |
66 |
| - |
67 |
| - // CHECK-LABEL: sil shared @_TZFCF19partial_apply_superU_FT_T_L_7Derived11classMethodfT_T_ |
68 |
| - // CHECK: [[DOFOO:%[0-9]+]] = function_ref @_TF19partial_apply_super5doFooFFT_T_T_ |
69 |
| - // CHECK: [[CASTED_SELF:%[0-9]+]] = upcast %0 : $@thick Derived.Type to $@thick Base.Type |
70 |
| - // CHECK: [[SUPER_METHOD:%[0-9]+]] = super_method %0 : $@thick Derived.Type, #<anonymous function>Base.classMethod!1 |
71 |
| - // CHECK: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply %4(%3) : $@convention(thin) (@thick Base.Type) -> () |
72 |
| - // CHECK: apply [[DOFOO]]([[PARTIAL_APPLY]]) |
73 |
| - override class func classMethod() { |
74 |
| - doFoo(super.classMethod) |
75 |
| - } |
76 |
| - } |
77 |
| -} |
| 62 | +// closure.GenericChild.classMethod |
| 63 | +// SILGEN-LABEL: sil shared @_TZFCF19partial_apply_superU0_FT_T_L_12GenericChild11classMethodfT_T_ : $@convention(thin) <A> (@thick GenericChild<A>.Type) -> () |
| 64 | +// SILGEN: [[DOFOO:%[0-9]+]] = function_ref @_TF14OutsideClasses5doFooFFT_T_T_ : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
| 65 | +// SILGEN: [[CASTED_SELF:%[0-9]+]] = upcast {{%[0-9]+}} : $@thick GenericChild<A>.Type to $@thick GenericParent<A>.Type |
| 66 | +// SILGEN: [[SUPER_METHOD:%[0-9]+]] = super_method {{%[0-9]+}} : $@thick GenericChild<A>.Type, #GenericParent.classMethod!1 : <A> GenericParent<A>.Type -> () -> () , $@convention(thin) <τ_0_0> (@thick GenericParent<τ_0_0>.Type) -> () |
| 67 | +// SILGEN: [[PARTIAL_APPLY:%[0-9]+]] = partial_apply [[SUPER_METHOD]]<A>([[CASTED_SELF]]) : $@convention(thin) <τ_0_0> (@thick GenericParent<τ_0_0>.Type) -> () |
| 68 | +// SILGEN: apply [[DOFOO]]([[PARTIAL_APPLY]]) : $@convention(thin) (@owned @callee_owned () -> ()) -> () |
0 commit comments