Extract Function: Approximate non-resolvable types with nearest resolvable supertype when possible

#KT-7120 Fixed
This commit is contained in:
Alexey Sedunov
2015-03-27 13:42:43 +03:00
parent a90d020859
commit eb594a2897
22 changed files with 224 additions and 86 deletions
@@ -1 +1 @@
Cannot extract method since following types are not denotable in the target scope: <no name provided>
Following declarations are used outside of selected code fragment: override fun call(): Int
@@ -1,15 +1,5 @@
trait Callable<T> {
fun call(): T
}
trait T
fun foo(a: Int): Int {
// SIBLING:
val o = object: Callable<Int> {
val b: Int = 1
override fun call(): Int {
return <selection>a + b</selection>
}
}
return o.call()
fun foo(): T {
return <selection>object: T() {}</selection>
}
@@ -0,0 +1,7 @@
trait T
fun foo(): T {
return t()
}
private fun t() = object : T() {}
@@ -0,0 +1,15 @@
trait Callable<T> {
fun call(): T
}
fun foo(a: Int): Int {
// SIBLING:
val o = object: Callable<Int> {
val b: Int = 1
override fun call(): Int {
return <selection>a + b</selection>
}
}
return o.call()
}
@@ -0,0 +1,10 @@
trait T
fun foo(): T {
class A: T
// SIBLING:
fun bar(): T {
return <selection>A()</selection>
}
}
@@ -0,0 +1,12 @@
trait T
fun foo(): T {
class A: T
fun a() = A()
// SIBLING:
fun bar(): T {
return a()
}
}
@@ -0,0 +1,13 @@
// PARAM_DESCRIPTOR: val a: foo.A defined in foo.bar
// PARAM_TYPES: T
trait T
// SIBLING:
fun foo(): T {
class A: T
fun bar(): T {
val a = A()
return <selection>a</selection>
}
}
@@ -0,0 +1,15 @@
// PARAM_DESCRIPTOR: val a: foo.A defined in foo.bar
// PARAM_TYPES: T
trait T
// SIBLING:
fun foo(): T {
class A: T
fun bar(): T {
val a = A()
return t(a)
}
}
private fun t(a: T) = a
@@ -0,0 +1,13 @@
// PARAM_DESCRIPTOR: val a: foo.A defined in foo.bar
// PARAM_TYPES: foo.A, T
trait T
fun foo(): T {
class A: T
// SIBLING:
fun bar(): T {
val a = A()
return <selection>a</selection>
}
}
@@ -0,0 +1,15 @@
// PARAM_DESCRIPTOR: val a: foo.A defined in foo.bar
// PARAM_TYPES: foo.A, T
trait T
fun foo(): T {
class A: T
fun a(a: A) = a
// SIBLING:
fun bar(): T {
val a = A()
return a(a)
}
}
@@ -0,0 +1,11 @@
trait T
// SIBLING:
fun foo(): T {
class A: T
fun bar(): A {
val a = A()
return <selection>a</selection>
}
}
@@ -0,0 +1 @@
Cannot extract method since following types are not denotable in the target scope: A