Extract Function: Replace non-denotable parameter types with their super types when possible

#KT-6187 Fixed
This commit is contained in:
Alexey Sedunov
2014-11-12 19:10:11 +03:00
parent 94efdeb3d5
commit 558e038ba5
9 changed files with 141 additions and 29 deletions
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// SIBLING:
val x = object {
val t = 1
fun test() {
<selection>println(this.t)</selection>
}
}
@@ -0,0 +1 @@
Cannot extract method since following types are not denotable in the target scope: &lt;no name provided&gt;
@@ -0,0 +1,10 @@
// PARAM_DESCRIPTOR: internal final class <no name provided> defined in root package
// PARAM_TYPES: kotlin.Any
// WITH_RUNTIME
// SIBLING:
val x = object {
fun test() {
<selection>println(this)</selection>
}
}
@@ -0,0 +1,14 @@
// PARAM_DESCRIPTOR: internal final class <no name provided> defined in root package
// PARAM_TYPES: kotlin.Any
// WITH_RUNTIME
// SIBLING:
val x = object {
fun test() {
unit()
}
}
private fun Any.unit() {
println(this)
}
@@ -0,0 +1,17 @@
// PARAM_DESCRIPTOR: val x: <no name provided> defined in test
// PARAM_TYPES: A
// WITH_RUNTIME
open class A {
}
fun foo(a: A) {
}
// SIBLING:
fun test() {
val x = object: A() { }
<selection>foo(x)</selection>
}
@@ -0,0 +1,21 @@
// PARAM_DESCRIPTOR: val x: <no name provided> defined in test
// PARAM_TYPES: A
// WITH_RUNTIME
open class A {
}
fun foo(a: A) {
}
// SIBLING:
fun test() {
val x = object: A() { }
unit(x)
}
private fun unit(x: A) {
foo(x)
}