ConvertIfWithThrowToAssertIntention: generate assert with lazy argument

This commit is contained in:
Natalia Ukhorskaya
2015-12-16 15:24:28 +03:00
parent 2dc1ba1d62
commit 2c29f6f5ab
7 changed files with 7 additions and 7 deletions
@@ -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,6 +1,6 @@
// WITH_RUNTIME
fun foo() {
kotlin.assert(!true, "text")
kotlin.assert(!true) { "text" }
}
fun assert(x: Boolean, y: Any) {}
@@ -2,7 +2,7 @@
package foo.kotlin
fun foo() {
kotlin.assert(!true, "text")
kotlin.assert(!true) { "text" }
}
fun assert(x: Boolean, y: Any) {}
@@ -1,5 +1,5 @@
// WITH_RUNTIME
fun foo() {
val x = true
assert(!(x && false), "text")
assert(!(x && false)) { "text" }
}
@@ -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,4 +1,4 @@
// WITH_RUNTIME
fun foo() {
assert(1 != 0, "text")
assert(1 != 0) { "text" }
}