Introduce "Add '== true'" quick fix for TYPE_MISMATCH

#KT-39930 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-07-02 15:55:36 +09:00
committed by Dmitry Gridin
parent 5bf18c09bb
commit efdeb7b449
11 changed files with 140 additions and 5 deletions
+10
View File
@@ -0,0 +1,10 @@
// "Add '== true'" "false"
// DISABLE-ERRORS
class Foo {
fun bar() = ""
}
fun test(foo: Foo?) {
if (foo?.bar()<caret>) {
}
}
+14
View File
@@ -0,0 +1,14 @@
// "Add '== true'" "false"
// DISABLE-ERRORS
// ACTION: Add 'toString()' call
// ACTION: Change parameter 's' type of function 'baz' to 'Boolean?'
// ACTION: Create function 'baz'
class Foo {
fun bar() = true
}
fun baz(s: String) {}
fun test(foo: Foo?) {
baz(foo?.bar()<caret>)
}
+9
View File
@@ -0,0 +1,9 @@
// "Add '== true'" "true"
class Foo {
fun bar() = true
}
fun test(foo: Foo?) {
if (foo?.bar()<caret>) {
}
}
+9
View File
@@ -0,0 +1,9 @@
// "Add '== true'" "true"
class Foo {
fun bar() = true
}
fun test(foo: Foo?) {
if (foo?.bar() == true) {
}
}
+10
View File
@@ -0,0 +1,10 @@
// "Add '== true'" "true"
class Foo {
fun bar() = true
}
fun baz(b: Boolean) {}
fun test(foo: Foo?) {
baz(foo?.bar()<caret>)
}
+10
View File
@@ -0,0 +1,10 @@
// "Add '== true'" "true"
class Foo {
fun bar() = true
}
fun baz(b: Boolean) {}
fun test(foo: Foo?) {
baz(foo?.bar() == true)
}