Error on 'if' without an 'else' branch when used as an expression
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
fun box(): String {
|
||||
if (true);
|
||||
if (false);
|
||||
val iftrue = if (true);
|
||||
val iffalse = if (false);
|
||||
|
||||
var state = 0
|
||||
val k = if (state++==1);
|
||||
if (state != 1) return "Fail: $state"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
fun box(): String {
|
||||
val a = if(true) {
|
||||
}
|
||||
return if (a.toString() == "kotlin.Unit") "OK" else "fail"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fun foo(condition: Boolean): String {
|
||||
val u = if (condition) {
|
||||
"OK"
|
||||
} else {
|
||||
}
|
||||
return u.toString()
|
||||
}
|
||||
|
||||
fun box() = foo(true)
|
||||
+7
-2
@@ -1,5 +1,10 @@
|
||||
fun unsupportedEx() = if (true) throw UnsupportedOperationException()
|
||||
fun runtimeEx() = if (true) throw RuntimeException()
|
||||
fun unsupportedEx() {
|
||||
if (true) throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun runtimeEx() {
|
||||
if (true) throw RuntimeException()
|
||||
}
|
||||
|
||||
fun test1() : String {
|
||||
var s = "";
|
||||
|
||||
+7
-2
@@ -1,5 +1,10 @@
|
||||
fun unsupportedEx() = if (true) throw UnsupportedOperationException()
|
||||
fun runtimeEx() = if (true) throw RuntimeException()
|
||||
fun unsupportedEx() {
|
||||
if (true) throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun runtimeEx() {
|
||||
if (true) throw RuntimeException()
|
||||
}
|
||||
|
||||
fun test1WithFinally() : String {
|
||||
var s = "";
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// This test checks that our bytecode is consistent with javac bytecode
|
||||
|
||||
fun _assert(condition: Boolean): Unit =
|
||||
fun _assert(condition: Boolean) {
|
||||
if (!condition) throw AssertionError("Fail")
|
||||
}
|
||||
|
||||
fun _assertFalse(condition: Boolean) = _assert(!condition)
|
||||
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ class A (val p: String, p1: String, p2: String) {
|
||||
|
||||
var cond2: String = ""
|
||||
|
||||
val prop1 = if (cond1(p)) p1
|
||||
val prop1 = if (cond1(p)) p1 else null
|
||||
|
||||
val prop2 = if (cond2(p)) else;
|
||||
val prop2 = if (cond2(p)) p2 else null;
|
||||
|
||||
|
||||
fun cond1(p: String): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user