Skip to content

Commit 80852e7

Browse files
committed
[di] Show the swift code necessary to generate some of the derived self cases.
This will make it easier to understand how these test cases come up in the wild. rdar://31880847
1 parent 970f020 commit 80852e7

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/SILOptimizer/definite_init_markuninitialized_derivedself.sil

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ sil @getSomeOptionalClass : $@convention(thin) () -> Optional<SomeClass>
4040
// Tests //
4141
///////////
4242

43+
// This can be generated by using:
44+
//
45+
// func makesInt() -> Int { return 0 }
46+
// func takesIntInout(i: inout Int) -> () {}
47+
//
48+
// class RootClassWithIVars {
49+
// var x: Int
50+
// var y: Int
51+
// var z: (Int, Int)
52+
// init() {
53+
// }
54+
// }
55+
//
56+
// class DerivedClassWithIVars : RootClassWithIVars {
57+
// var a: Int
58+
// override init() {
59+
// a = makesInt()
60+
// }
61+
// }
62+
//
4363
sil @derived_test1 : $@convention(method) (@owned DerivedClassWithIVars) -> @owned DerivedClassWithIVars {
4464
bb0(%0 : $DerivedClassWithIVars):
4565
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
@@ -70,6 +90,24 @@ bb0(%0 : $DerivedClassWithIVars):
7090
return %18 : $DerivedClassWithIVars
7191
}
7292

93+
// This is testing the following swift:
94+
//
95+
// func makesInt() -> Int { return 0 }
96+
// func takesIntInout(i: inout Int) -> () {}
97+
//
98+
// class RootClassWithIVars {
99+
// var x: Int
100+
// var y: Int
101+
// var z: (Int, Int)
102+
// init() {
103+
// }
104+
// }
105+
//
106+
// class DerivedClassWithIVars : RootClassWithIVars {
107+
// var a: Int
108+
// override init() {
109+
// }
110+
// }
73111
sil @derived_test2 : $@convention(method) (@owned DerivedClassWithIVars) -> @owned DerivedClassWithIVars {
74112
bb0(%0 : $DerivedClassWithIVars):
75113
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
@@ -167,6 +205,21 @@ bb0(%0 : $DerivedClassWithNontrivialStoredProperties):
167205
}
168206

169207
// <rdar://problem/18199087> DI doesn't catch use of super properties lexically inside super.init call
208+
//
209+
// To recreate this:
210+
//
211+
// class Foo {
212+
// var x: Int
213+
// init() {}
214+
// init(i: Int) {}
215+
// }
216+
//
217+
// class Foo2 : Foo {
218+
// override init() {
219+
// super.init(i: self.x) // <--- The important part.
220+
// }
221+
// }
222+
//
170223
sil @super_init_out_of_order : $@convention(method) (@owned DerivedClassWithIVars, Int) -> @owned DerivedClassWithIVars {
171224
bb0(%0 : $DerivedClassWithIVars, %i : $Int):
172225
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>

0 commit comments

Comments
 (0)