Remove 'DataFlowValueKindUtils.isStable', use 'DataFlowValue.isStable' instead
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
var a: String? = "A"
|
||||
val a1 = a
|
||||
doSomething(if (a1 != null) a1 else throw NullPointerException("Expression 'a' must not be null"))
|
||||
doSomething(if (a != null) a else throw NullPointerException("Expression 'a' must not be null"))
|
||||
}
|
||||
|
||||
fun doSomething(a: Any){}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class My(val x: Int?)
|
||||
fun foo(arg: Any) {
|
||||
val y = if ((arg as? My)?.x != null) (arg as? My)?.x else 42
|
||||
val x = (arg as? My)?.x
|
||||
val y = if (x != null) x else 42
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
fun main(args: Array<String>) {
|
||||
var a: String? = "A"
|
||||
val a1 = a
|
||||
if (a1 != null) a1 else "bar"
|
||||
if (a != null) a else "bar"
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
val bar = if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
return foo
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
val bar = foo!!
|
||||
return foo
|
||||
}
|
||||
+8
-1
@@ -1,11 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
//IS_APPLICABLE: false
|
||||
// IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun capture(block: () -> Unit): Unit = Unit
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var foo = maybeFoo()
|
||||
|
||||
capture {
|
||||
foo = null
|
||||
}
|
||||
|
||||
if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
val bar = if (foo == null<caret>)
|
||||
"hello"
|
||||
else
|
||||
foo
|
||||
return foo
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
val bar = foo ?: "hello"
|
||||
return foo
|
||||
}
|
||||
@@ -111,4 +111,12 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>applicableForLocalStableVar.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/applicableForLocalStableVar.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun capture(block: () -> Unit): Unit = Unit
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
|
||||
capture {
|
||||
foo = null
|
||||
}
|
||||
|
||||
val bar = if (foo == null<caret>)
|
||||
42
|
||||
else
|
||||
foo
|
||||
|
||||
return foo
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
//IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var foo = maybeFoo()
|
||||
if (foo == null<caret>)
|
||||
"bar"
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -2,7 +2,6 @@ fun <T> doSomething(a: T) {}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var a: String? = "A"
|
||||
val a1 = a
|
||||
doSomething(if (a1 != null) a1.length else null)
|
||||
doSomething(if (a != null) a.length else null)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user