ConvertIfWithThrowToAssertIntention: generate assert with lazy argument
This commit is contained in:
+1
-1
@@ -60,7 +60,7 @@ public class ConvertIfWithThrowToAssertIntention : SelfTargetingOffsetIndependen
|
||||
|
||||
val arg = thrownExpr.getValueArguments().singleOrNull()?.getArgumentExpression()
|
||||
val assertExpr = if (arg != null && !arg.isNullExpression())
|
||||
psiFactory.createExpressionByPattern("kotlin.assert($0, $1)", newCondition, arg)
|
||||
psiFactory.createExpressionByPattern("kotlin.assert($0) {$1}", newCondition, arg)
|
||||
else
|
||||
psiFactory.createExpressionByPattern("kotlin.assert($0)", newCondition)
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
kotlin.assert(!true, "text")
|
||||
kotlin.assert(!true) { "text" }
|
||||
}
|
||||
|
||||
fun assert(x: Boolean, y: Any) {}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
package foo.kotlin
|
||||
|
||||
fun foo() {
|
||||
kotlin.assert(!true, "text")
|
||||
kotlin.assert(!true) { "text" }
|
||||
}
|
||||
|
||||
fun assert(x: Boolean, y: Any) {}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
val x = true
|
||||
assert(!(x && false), "text")
|
||||
assert(!(x && false)) { "text" }
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
assert(!true, "text")
|
||||
assert(!true) { "text" }
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
assert(!true, "text")
|
||||
assert(!true) { "text" }
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo() {
|
||||
assert(1 != 0, "text")
|
||||
assert(1 != 0) { "text" }
|
||||
}
|
||||
Reference in New Issue
Block a user