Added IfThenToDoubleBangIntention
This commit is contained in:
committed by
Zalim Bashorov
parent
8476a790bd
commit
aec5ae5dd4
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
throw NullPointerException()
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"foo"!!
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo != null<caret>) {
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"foo"!!
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (foo() == null<caret>) {
|
||||
throw KotlinNullPointerException()
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()!!
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"foo"!!
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
|
||||
if (foo != null<caret>) {
|
||||
print ("Hello")
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
val a = "a"
|
||||
|
||||
if (foo != null<caret>) {
|
||||
a
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (null == <caret>null) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun <T> T.compareTo(a: T): Int = 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
if (foo > null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Boolean</td></tr><tr><td>Found:</td><td>kotlin.Int</td></tr></table></html>
|
||||
// ERROR: Condition must be of type kotlin.Boolean, but is of type kotlin.Int
|
||||
// ERROR: Infix call corresponds to a dot-qualified call 'foo.times(10)' which is not allowed on a nullable receiver 'foo'. Use ?.-qualified call instead
|
||||
|
||||
fun String?.times(a: Int): Boolean = a == 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo: Int? = 4
|
||||
if (foo * 10<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
print(foo)
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
print(foo)
|
||||
foo!!
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
val x = maybeFoo()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (x !=<caret> null) {
|
||||
x
|
||||
} else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
val x = maybeFoo()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
x!!
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
if (<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
}
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo != null<caret>)
|
||||
foo
|
||||
else
|
||||
throw NullPointerException()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
val x = if (foo == null<caret>) {
|
||||
throw KotlinNullPointerException()
|
||||
}
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val x = maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo != null<caret>)
|
||||
foo
|
||||
else
|
||||
throw NullPointerException("'foo' must not be null")
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>)
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Boolean</td></tr><tr><td>Found:</td><td>() → kotlin.String?</td></tr></table></html>
|
||||
// ERROR: Condition must be of type kotlin.Boolean, but is of type () -> kotlin.String?
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if<caret> {
|
||||
foo
|
||||
} else throw NullPointerException()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
val bar = "bar"
|
||||
if (foo == bar<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
//IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (maybeFoo() == null<caret>)
|
||||
maybeFoo()
|
||||
else
|
||||
throw NullPointerException()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
//IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var foo = maybeFoo()
|
||||
if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
null
|
||||
}
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
print ("Hello")
|
||||
throw NullPointerException("'foo' must not be null")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (null == foo<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (null != foo<caret>)
|
||||
foo
|
||||
else
|
||||
throw NullPointerException()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
if (foo == null<caret>) {
|
||||
null
|
||||
}
|
||||
else {
|
||||
null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
class NullPointerException : Exception()
|
||||
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (foo() == null<caret>) {
|
||||
throw java.lang.NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
class NullPointerException : Exception()
|
||||
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()!!
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val y = if (foo == null<caret>) {
|
||||
throw NullPointerException()
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: FALSE
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val y = if (foo == null<caret>) {
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
class F(a: Int?) {
|
||||
val b = a
|
||||
val c = if (b != <caret> null) b else throw NullPointerException()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
F(1).c
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
class F(a: Int?) {
|
||||
val b = a
|
||||
val c = b!!
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
F(1).c
|
||||
}
|
||||
Reference in New Issue
Block a user