Error on 'if' without an 'else' branch when used as an expression

This commit is contained in:
Yan Zhulanow
2015-10-13 18:13:51 +03:00
parent de5dc61820
commit e14c9645dc
29 changed files with 121 additions and 91 deletions
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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 {
@@ -6,9 +6,9 @@ class A (val p: String, p1: String, p2: String) {
val prop: String = if (p == "test") p1 else p2
val prop1 = if (cond1(p)) p1
val prop1 = if (cond1(p)) p1 else false
val prop2 = if (cond2(p)) else;
val prop2 = if (cond2(p)) true else false
fun cond1(p: String): Boolean {
cond1 = "cond1"