Skip to content

Commit d44cdf4

Browse files
authored
Merge pull request #10646 from gottesmm/improve_tests_for_superref
2 parents 7580d6a + dcb954a commit d44cdf4

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

test/SILGen/super.swift

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,49 +83,71 @@ public class GreatGrandchild : Grandchild {
8383
public class ChildToResilientParent : ResilientOutsideParent {
8484
// CHECK-LABEL: sil @_T05super22ChildToResilientParentC6methodyyF : $@convention(method) (@guaranteed ChildToResilientParent) -> ()
8585
public override func method() {
86-
// CHECK: [[COPY:%.*]] = copy_value %0
87-
// CHECK: super_method [[COPY]] : $ChildToResilientParent, #ResilientOutsideParent.method!1 : (ResilientOutsideParent) -> () -> (), $@convention(method) (@guaranteed ResilientOutsideParent) -> ()
88-
// CHECK: return
86+
// CHECK: bb0([[SELF:%.*]] : $ChildToResilientParent):
87+
// CHECK: [[COPY_SELF:%.*]] = copy_value [[SELF]]
88+
// CHECK: [[UPCAST_SELF:%.*]] = upcast [[COPY_SELF]]
89+
// CHECK: [[FUNC:%.*]] = super_method [[COPY_SELF]] : $ChildToResilientParent, #ResilientOutsideParent.method!1 : (ResilientOutsideParent) -> () -> (), $@convention(method) (@guaranteed ResilientOutsideParent) -> ()
90+
// CHECK: apply [[FUNC]]([[UPCAST_SELF]])
8991
super.method()
9092
}
93+
// CHECK: } // end sil function '_T05super22ChildToResilientParentC6methodyyF'
9194

9295
// CHECK-LABEL: sil @_T05super22ChildToResilientParentC11classMethodyyFZ : $@convention(method) (@thick ChildToResilientParent.Type) -> ()
9396
public override class func classMethod() {
94-
// CHECK: super_method %0 : $@thick ChildToResilientParent.Type, #ResilientOutsideParent.classMethod!1 : (ResilientOutsideParent.Type) -> () -> (), $@convention(method) (@thick ResilientOutsideParent.Type) -> ()
95-
// CHECK: return
97+
// CHECK: bb0([[METASELF:%.*]] : $@thick ChildToResilientParent.Type):
98+
// CHECK: [[UPCAST_METASELF:%.*]] = upcast [[METASELF]]
99+
// CHECK: [[FUNC:%.*]] = super_method [[SELF]] : $@thick ChildToResilientParent.Type, #ResilientOutsideParent.classMethod!1 : (ResilientOutsideParent.Type) -> () -> (), $@convention(method) (@thick ResilientOutsideParent.Type) -> ()
100+
// CHECK: apply [[FUNC]]([[UPCAST_METASELF]])
96101
super.classMethod()
97102
}
103+
// CHECK: } // end sil function '_T05super22ChildToResilientParentC11classMethodyyFZ'
98104

99105
// CHECK-LABEL: sil @_T05super22ChildToResilientParentC11returnsSelfACXDyFZ : $@convention(method) (@thick ChildToResilientParent.Type) -> @owned ChildToResilientParent
100106
public class func returnsSelf() -> Self {
101-
// CHECK: super_method %0 : $@thick ChildToResilientParent.Type, #ResilientOutsideParent.classMethod!1 : (ResilientOutsideParent.Type) -> () -> ()
107+
// CHECK: bb0([[METASELF:%.*]] : $@thick ChildToResilientParent.Type):
108+
// CHECK: [[CAST_METASELF:%.*]] = unchecked_trivial_bit_cast [[METASELF]] : $@thick ChildToResilientParent.Type to $@thick @dynamic_self ChildToResilientParent.Type
109+
// CHECK: [[UPCAST_CAST_METASELF:%.*]] = upcast [[CAST_METASELF]] : $@thick @dynamic_self ChildToResilientParent.Type to $@thick ResilientOutsideParent.Type
110+
// CHECK: [[FUNC:%.*]] = super_method [[METASELF]] : $@thick ChildToResilientParent.Type, #ResilientOutsideParent.classMethod!1 : (ResilientOutsideParent.Type) -> () -> ()
111+
// CHECK: apply [[FUNC]]([[UPCAST_CAST_METASELF]])
102112
// CHECK: unreachable
103113
super.classMethod()
104114
}
115+
// CHECK: } // end sil function '_T05super22ChildToResilientParentC11returnsSelfACXDyFZ'
105116
}
106117

107118
public class ChildToFixedParent : OutsideParent {
108119
// CHECK-LABEL: sil @_T05super18ChildToFixedParentC6methodyyF : $@convention(method) (@guaranteed ChildToFixedParent) -> ()
109120
public override func method() {
110-
// CHECK: [[COPY:%.*]] = copy_value %0
111-
// CHECK: super_method [[COPY]] : $ChildToFixedParent, #OutsideParent.method!1 : (OutsideParent) -> () -> (), $@convention(method) (@guaranteed OutsideParent) -> ()
112-
// CHECK: return
121+
// CHECK: bb0([[SELF:%.*]] : $ChildToFixedParent):
122+
// CHECK: [[COPY_SELF:%.*]] = copy_value [[SELF]]
123+
// CHECK: [[UPCAST_COPY_SELF:%.*]] = upcast [[COPY_SELF]]
124+
// CHECK: [[FUNC:%.*]] = super_method [[COPY_SELF]] : $ChildToFixedParent, #OutsideParent.method!1 : (OutsideParent) -> () -> (), $@convention(method) (@guaranteed OutsideParent) -> ()
125+
// CHECK: apply [[FUNC]]([[UPCAST_COPY_SELF]])
113126
super.method()
114127
}
128+
// CHECK: } // end sil function '_T05super18ChildToFixedParentC6methodyyF'
115129

116130
// CHECK-LABEL: sil @_T05super18ChildToFixedParentC11classMethodyyFZ : $@convention(method) (@thick ChildToFixedParent.Type) -> ()
117131
public override class func classMethod() {
118-
// CHECK: super_method %0 : $@thick ChildToFixedParent.Type, #OutsideParent.classMethod!1 : (OutsideParent.Type) -> () -> (), $@convention(method) (@thick OutsideParent.Type) -> ()
119-
// CHECK: return
132+
// CHECK: bb0([[SELF:%.*]] : $@thick ChildToFixedParent.Type):
133+
// CHECK: [[UPCAST_SELF:%.*]] = upcast [[SELF]]
134+
// CHECK: [[FUNC:%.*]] = super_method [[SELF]] : $@thick ChildToFixedParent.Type, #OutsideParent.classMethod!1 : (OutsideParent.Type) -> () -> (), $@convention(method) (@thick OutsideParent.Type) -> ()
135+
// CHECK: apply [[FUNC]]([[UPCAST_SELF]])
120136
super.classMethod()
121137
}
138+
// CHECK: } // end sil function '_T05super18ChildToFixedParentC11classMethodyyFZ'
122139

123140
// CHECK-LABEL: sil @_T05super18ChildToFixedParentC11returnsSelfACXDyFZ : $@convention(method) (@thick ChildToFixedParent.Type) -> @owned ChildToFixedParent
124141
public class func returnsSelf() -> Self {
125-
// CHECK: super_method %0 : $@thick ChildToFixedParent.Type, #OutsideParent.classMethod!1 : (OutsideParent.Type) -> () -> ()
126-
// CHECK: unreachable
142+
// CHECK: bb0([[SELF:%.*]] : $@thick ChildToFixedParent.Type):
143+
// CHECK: [[FIRST_CAST:%.*]] = unchecked_trivial_bit_cast [[SELF]]
144+
// CHECK: [[SECOND_CAST:%.*]] = upcast [[FIRST_CAST]]
145+
// CHECK: [[FUNC:%.*]] = super_method [[SELF]] : $@thick ChildToFixedParent.Type, #OutsideParent.classMethod!1 : (OutsideParent.Type) -> () -> ()
146+
// CHECK: apply [[FUNC]]([[SECOND_CAST]])
147+
// CHECK: unreachable
127148
super.classMethod()
128149
}
150+
// CHECK: } // end sil function '_T05super18ChildToFixedParentC11returnsSelfACXDyFZ'
129151
}
130152

131153
public extension ResilientOutsideChild {
@@ -150,11 +172,12 @@ public class GenericDerived<T> : GenericBase<T> {
150172
{
151173
super.method()
152174
}()
175+
// CHECK: } // end sil function '_T05super14GenericDerivedC6methodyyFyycfU_'
153176

154177
// CHECK-LABEL: sil private @_T05super14GenericDerivedC6methodyyF13localFunctionL_yylF : $@convention(thin) <T> (@owned GenericDerived<T>) -> ()
155178
// CHECK: upcast {{.*}} : $GenericDerived<T> to $GenericBase<T>
156179
// CHECK: return
157-
180+
// CHECK: } // end sil function '_T05super14GenericDerivedC6methodyyF13localFunctionL_yylF'
158181
func localFunction() {
159182
super.method()
160183
}
@@ -166,6 +189,7 @@ public class GenericDerived<T> : GenericBase<T> {
166189
func genericFunction<U>(_: U) {
167190
super.method()
168191
}
192+
// CHECK: } // end sil function '_T05super14GenericDerivedC6methodyyF15genericFunctionL_yqd__r__lF'
169193
genericFunction(0)
170194
}
171195
}

0 commit comments

Comments
 (0)