Fix "Replace !! with if-then" inspection in receiver position
#KT-5412 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
162de77b71
commit
1455451601
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
class A {
|
||||
fun f(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a: A? = A()
|
||||
a<caret>!!.f()
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
class A {
|
||||
fun f(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a: A? = A()
|
||||
if (a != null) a.f() else throw NullPointerException("Expression 'a' must not be null")
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
class A {
|
||||
val g = 44
|
||||
fun f(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a: A? = A()
|
||||
a<caret>!!.g
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
class A {
|
||||
val g = 44
|
||||
fun f(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a: A? = A()
|
||||
if (a != null) a.g else throw NullPointerException("Expression 'a' must not be null")
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
class A {
|
||||
fun f(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a: A? = A()
|
||||
val b = a<caret>!!.f()
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
class A {
|
||||
fun f(): Int {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val a: A? = A()
|
||||
val b = if (a != null) a.f() else throw NullPointerException("Expression 'a' must not be null")
|
||||
}
|
||||
Reference in New Issue
Block a user