Cast to type quick-fix: handle case with qualified elements correctly

Same fix for 'add !!' fix
So #KT-18368 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-07-20 16:43:00 +03:00
parent e6872c52a3
commit a08f55cf99
6 changed files with 74 additions and 2 deletions
@@ -0,0 +1,13 @@
// "Add non-null asserted (!!) call" "true"
// WITH_RUNTIME
class A {
fun foo(): List<Int?> = listOf()
fun bar(i : Int, s: String) = Unit
fun use() {
val a = A()
a.bar(a.foo().<caret>single(), "Asd")
}
}
@@ -0,0 +1,13 @@
// "Add non-null asserted (!!) call" "true"
// WITH_RUNTIME
class A {
fun foo(): List<Int?> = listOf()
fun bar(i : Int, s: String) = Unit
fun use() {
val a = A()
a.bar(a.foo().single()!!, "Asd")
}
}
@@ -0,0 +1,12 @@
// "Cast expression 'a.foo().single()' to 'Int'" "true"
// WITH_RUNTIME
class A {
fun foo(): List<Any> = listOf()
fun bar(i : Int, s: String) = Unit
fun use() {
val a = A()
a.bar(a.foo().single<caret>(), "Asd")
}
}
@@ -0,0 +1,12 @@
// "Cast expression 'a.foo().single()' to 'Int'" "true"
// WITH_RUNTIME
class A {
fun foo(): List<Any> = listOf()
fun bar(i : Int, s: String) = Unit
fun use() {
val a = A()
a.bar(a.foo().single() as Int, "Asd")
}
}