Extract Function: Approximate non-resolvable types with nearest resolvable supertype when possible
#KT-7120 Fixed
This commit is contained in:
+3
-13
@@ -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>
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
trait T
|
||||
|
||||
fun foo(): T {
|
||||
return t()
|
||||
}
|
||||
|
||||
private fun t() = object : T() {}
|
||||
+15
@@ -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()
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
trait T
|
||||
|
||||
fun foo(): T {
|
||||
class A: T
|
||||
|
||||
// SIBLING:
|
||||
fun bar(): T {
|
||||
return <selection>A()</selection>
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
trait T
|
||||
|
||||
fun foo(): T {
|
||||
class A: T
|
||||
|
||||
fun a() = A()
|
||||
|
||||
// SIBLING:
|
||||
fun bar(): T {
|
||||
return a()
|
||||
}
|
||||
}
|
||||
+13
@@ -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>
|
||||
}
|
||||
}
|
||||
+15
@@ -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
|
||||
+13
@@ -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>
|
||||
}
|
||||
}
|
||||
+15
@@ -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)
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
trait T
|
||||
|
||||
// SIBLING:
|
||||
fun foo(): T {
|
||||
class A: T
|
||||
|
||||
fun bar(): A {
|
||||
val a = A()
|
||||
return <selection>a</selection>
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
Cannot extract method since following types are not denotable in the target scope: A
|
||||
Reference in New Issue
Block a user