Fix "smart step into" for classes with complex hierarchy (KT-16667)

#KT-16667 Fixed
This commit is contained in:
Nikolay Krasko
2017-03-07 18:13:26 +03:00
parent 6d9b519bb2
commit e6ee933b27
9 changed files with 243 additions and 18 deletions
@@ -0,0 +1,11 @@
package smartStepIntoComponentFunction
data class Test(val a: Int, val b: Int)
fun main(args: Array<String>) {
val t = Test(12, 2)
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
t.component2()
}
@@ -0,0 +1,67 @@
package smartStepIntoWithDelegates
interface A {
fun foo(): String
}
class AA : A {
override fun foo(): String = "AA"
}
class B(a: A) : A by a {
override fun foo(): String = "B"
}
class C(b: B) : A by b
class D(a: A) : A by a
fun test1() {
val c: C = C(B(AA()))
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
c.foo() // 12
}
fun test2() {
val a: A = C(B(AA()))
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
a.foo() // 12
}
fun test3() {
val d: D = D(AA())
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
d.foo() // 8
}
fun test4() {
val aa: A = AA()
val c: B = B(AA())
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
aa.foo() + c.foo() // 8
}
fun test5() {
val aa: A = AA()
val c: B = B(AA())
// SMART_STEP_INTO_BY_INDEX: 2
// RESUME: 1
//Breakpoint!
aa.foo() + c.foo() // 12 (Shouldn't stop at B.foo() even it's evaluated before C.foo())
}
fun main(args: Array<String>) {
test1()
test2()
test3()
test4()
test5()
}
@@ -0,0 +1,66 @@
package smartStepIntoWithOverrides
abstract class A {
abstract fun foo(): String
}
open class B : A() {
override fun foo(): String = "B"
}
open class C : B() {
override fun foo(): String = "C"
}
class D : C()
fun test1() {
val d: D = D()
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
d.foo() // 12
}
fun test2() {
val a: A = B()
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
a.foo() // 8
}
fun test3() {
val a: A = C()
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
a.foo() // 12
}
fun test4() {
val a: A = B()
val d: D = D()
// SMART_STEP_INTO_BY_INDEX: 1
// RESUME: 1
//Breakpoint!
a.foo() + d.foo() // 8
}
fun test5() {
val a: A = B()
val d: D = D()
// SMART_STEP_INTO_BY_INDEX: 2
// RESUME: 1
//Breakpoint!
a.foo() + d.foo() // 12 (Shouldn't stop at B.foo() even it's evaluated before C.foo())
}
fun main(args: Array<String>) {
test1()
test2()
test3()
test4()
test5()
}