FIR IDE: Enable AddExclExclCallFix for UNSAFE_CALL,

UNSAFE_OPERATOR_CALL, UNSAFE_INFIX_CALL, ITERATOR_ON_NULLABLE,
ARGUMENT_TYPE_MISMATCH, RETURN_TYPE_MISMATCH.

TODO: Don't offer fix when target is known to be null (from data flow
analysis).
This commit is contained in:
Mark Punzalan
2021-04-25 21:39:25 +00:00
committed by Ilya Kirillov
parent 71a8d9c0bb
commit db82797f58
53 changed files with 311 additions and 42 deletions
@@ -7,4 +7,3 @@ class SafeType {
fun safeB(p: SafeType?) {
val v = p <caret>+ 42
}
/* IGNORE_FIR */
@@ -7,4 +7,3 @@ class SafeType {
fun safeB(p: SafeType?) {
val v = p!! + 42
}
/* IGNORE_FIR */
@@ -7,4 +7,3 @@ class SafeType {
fun safeB(p: SafeType?) {
val v = p <caret>op 42
}
/* IGNORE_FIR */
@@ -7,4 +7,3 @@ class SafeType {
fun safeB(p: SafeType?) {
val v = p!! op 42
}
/* IGNORE_FIR */
@@ -3,4 +3,3 @@ fun <T: Collection<Int>?> foo(c: T) {
for (i in <caret>c) { }
}
/* IGNORE_FIR */
@@ -3,4 +3,3 @@ fun <T: Collection<Int>?> foo(c: T) {
for (i in c!!) { }
}
/* IGNORE_FIR */
@@ -4,4 +4,3 @@ fun foo() {
for (i in <caret>test) { }
}
/* IGNORE_FIR */
@@ -4,4 +4,3 @@ fun foo() {
for (i in <caret>test!!) { }
}
/* IGNORE_FIR */
@@ -7,4 +7,3 @@ class SafeType {
fun safeB(p: SafeType?) {
val v = <caret>-p
}
/* IGNORE_FIR */
@@ -7,4 +7,3 @@ class SafeType {
fun safeB(p: SafeType?) {
val v = -p!!
}
/* IGNORE_FIR */
@@ -1,4 +1,4 @@
// "class org.jetbrains.kotlin.idea.quickfix.AddExclExclCallFix" "false"
// "Add non-null asserted (!!) call" "false"
// ACTION: Replace with a 'forEach' function call
// ACTION: Surround with null check
// ERROR: Not nullable value required to call an 'iterator()' method on for-loop range
@@ -7,5 +7,3 @@ fun foo() {
val test: Some? = Some()
for (i in <caret>test) { }
}
/* IGNORE_FIR */
@@ -7,5 +7,3 @@ fun foo() {
val test: Some? = Some()
for (i in test!!) { }
}
/* IGNORE_FIR */
-1
View File
@@ -5,4 +5,3 @@ fun callMe(p: String) {}
fun callIt(p: Any) {
callMe(<caret>p as String?)
}
/* IGNORE_FIR */
-1
View File
@@ -5,4 +5,3 @@ fun callMe(p: String) {}
fun callIt(p: Any) {
callMe(<caret>(p as String?)!!)
}
/* IGNORE_FIR */
-2
View File
@@ -2,5 +2,3 @@
fun foo(a: Int?) {
a<caret>.plus(1)
}
/* IGNORE_FIR */
@@ -2,5 +2,3 @@
fun foo(a: Int?) {
a!!.plus(1)
}
/* IGNORE_FIR */
-2
View File
@@ -2,5 +2,3 @@
fun foo(a: Int?) {
a.<caret>plus(1)
}
/* IGNORE_FIR */
@@ -2,5 +2,3 @@
fun foo(a: Int?) {
a!!.plus(1)
}
/* IGNORE_FIR */
-1
View File
@@ -2,4 +2,3 @@
operator fun Int.get(row: Int, column: Int) = this
fun foo(arg: Int?) = arg<caret>[42, 13]
/* IGNORE_FIR */
@@ -2,4 +2,3 @@
operator fun Int.get(row: Int, column: Int) = this
fun foo(arg: Int?) = arg!![42, 13]
/* IGNORE_FIR */
-1
View File
@@ -2,4 +2,3 @@
operator fun Int.get(row: Int, column: Int) = if (row == column) this else null
fun foo(arg: Int) = arg[42, 13]<caret>.hashCode()
/* IGNORE_FIR */
@@ -2,4 +2,3 @@
operator fun Int.get(row: Int, column: Int) = if (row == column) this else null
fun foo(arg: Int) = arg[42, 13]!!.hashCode()
/* IGNORE_FIR */