Extract Function: Ignore internal smartcasts

#KT-8458 Fixed
This commit is contained in:
Alexey Sedunov
2015-09-03 17:08:37 +03:00
parent ba5d5cc87b
commit e03067846f
10 changed files with 230 additions and 39 deletions
@@ -0,0 +1,24 @@
// SUGGESTED_NAMES: i, getX
// PARAM_TYPES: kotlin.Any
// PARAM_DESCRIPTOR: value-parameter val o: kotlin.Any defined in foo
open class A {
val a = 1
}
interface T {
val t: Int
}
class B : A(), T {
override val t: Int = 2
}
fun foo(o: Any) {
val x = <selection>when (o) {
is A -> {
if (o is T) o.a + o.t else o.a
}
else -> o.hashCode()
}</selection>
}
@@ -0,0 +1,28 @@
// SUGGESTED_NAMES: i, getX
// PARAM_TYPES: kotlin.Any
// PARAM_DESCRIPTOR: value-parameter val o: kotlin.Any defined in foo
open class A {
val a = 1
}
interface T {
val t: Int
}
class B : A(), T {
override val t: Int = 2
}
fun foo(o: Any) {
val x = i(o)
}
private fun i(o: Any): Int {
return when (o) {
is A -> {
if (o is T) o.a + o.t else o.a
}
else -> o.hashCode()
}
}
@@ -0,0 +1,23 @@
// PARAM_TYPES: A
// PARAM_DESCRIPTOR: value-parameter val o: kotlin.Any defined in foo
open class A {
val a = 1
}
interface T {
val t: Int
}
class B : A(), T {
override val t: Int = 2
}
fun foo(o: Any) {
val x = when (o) {
is A -> {
<selection>if (o is T) o.a + o.t else o.a</selection>
}
else -> o.hashCode()
}
}
@@ -0,0 +1,25 @@
// PARAM_TYPES: A
// PARAM_DESCRIPTOR: value-parameter val o: kotlin.Any defined in foo
open class A {
val a = 1
}
interface T {
val t: Int
}
class B : A(), T {
override val t: Int = 2
}
fun foo(o: Any) {
val x = when (o) {
is A -> {
i(o)
}
else -> o.hashCode()
}
}
private fun i(o: A) = if (o is T) o.a + o.t else o.a
@@ -0,0 +1,20 @@
open class A {
val a = 1
}
interface T {
val t: Int
}
class B : A(), T {
override val t: Int = 2
}
fun foo(o: Any) {
val x = when (o) {
is A -> {
if (o is T) <selection>o.a + o.t</selection> else o.a
}
else -> o.hashCode()
}
}
@@ -0,0 +1 @@
Cannot extract method since following types are not denotable in the target scope: {A &amp; T}