Skip to content

[di] Show the swift code necessary to generate some of the derived self cases. #11021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions test/SILOptimizer/definite_init_markuninitialized_derivedself.sil
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ sil @getSomeOptionalClass : $@convention(thin) () -> Optional<SomeClass>
// Tests //
///////////

// This can be generated by using:
//
// func makesInt() -> Int { return 0 }
// func takesIntInout(i: inout Int) -> () {}
//
// class RootClassWithIVars {
// var x: Int
// var y: Int
// var z: (Int, Int)
// init() {
// }
// }
//
// class DerivedClassWithIVars : RootClassWithIVars {
// var a: Int
// override init() {
// a = makesInt()
// }
// }
//
sil @derived_test1 : $@convention(method) (@owned DerivedClassWithIVars) -> @owned DerivedClassWithIVars {
bb0(%0 : $DerivedClassWithIVars):
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
Expand Down Expand Up @@ -70,6 +90,24 @@ bb0(%0 : $DerivedClassWithIVars):
return %18 : $DerivedClassWithIVars
}

// This is testing the following swift:
//
// func makesInt() -> Int { return 0 }
// func takesIntInout(i: inout Int) -> () {}
//
// class RootClassWithIVars {
// var x: Int
// var y: Int
// var z: (Int, Int)
// init() {
// }
// }
//
// class DerivedClassWithIVars : RootClassWithIVars {
// var a: Int
// override init() {
// }
// }
sil @derived_test2 : $@convention(method) (@owned DerivedClassWithIVars) -> @owned DerivedClassWithIVars {
bb0(%0 : $DerivedClassWithIVars):
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
Expand Down Expand Up @@ -167,6 +205,21 @@ bb0(%0 : $DerivedClassWithNontrivialStoredProperties):
}

// <rdar://problem/18199087> DI doesn't catch use of super properties lexically inside super.init call
//
// To recreate this:
//
// class Foo {
// var x: Int
// init() {}
// init(i: Int) {}
// }
//
// class Foo2 : Foo {
// override init() {
// super.init(i: self.x) // <--- The important part.
// }
// }
//
sil @super_init_out_of_order : $@convention(method) (@owned DerivedClassWithIVars, Int) -> @owned DerivedClassWithIVars {
bb0(%0 : $DerivedClassWithIVars, %i : $Int):
%1 = alloc_box $<τ_0_0> { var τ_0_0 } <DerivedClassWithIVars>
Expand Down