Support missing when branch exception throwing. (#174)
This commit is contained in:
+3
@@ -68,6 +68,9 @@ private class BuiltinOperatorTransformer(val context: Context) : IrElementTransf
|
||||
irBuiltins.throwNpe -> IrCallImpl(expression.startOffset, expression.endOffset,
|
||||
builtIns.getKonanInternalFunctions("ThrowNullPointerException").single())
|
||||
|
||||
irBuiltins.noWhenBranchMatchedException -> IrCallImpl(expression.startOffset, expression.endOffset,
|
||||
builtIns.getKonanInternalFunctions("ThrowNoWhenBranchMatchedException").single())
|
||||
|
||||
else -> expression
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,6 +287,11 @@ task when7(type: RunKonanTest) {
|
||||
source = "codegen/branching/when7.kt"
|
||||
}
|
||||
|
||||
task when8(type: RunKonanTest) {
|
||||
source = "codegen/branching/when8.kt"
|
||||
goldValue = "true\n"
|
||||
}
|
||||
|
||||
task when_through(type: RunKonanTest) {
|
||||
source = "codegen/branching/when_through.kt"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun main(args: Array<String>) {
|
||||
when (true) {
|
||||
true -> println("true")
|
||||
false -> println("false")
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -1,7 +1,3 @@
|
||||
#kotlin_version=1.1-M02
|
||||
kotlin_version=1.1-M03
|
||||
#kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20161201.112229-281
|
||||
#kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20161209.125829-302
|
||||
#kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20161217.025654-317
|
||||
#kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20161219.154657-321
|
||||
kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20161224.154011-334
|
||||
#kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-SNAPSHOT
|
||||
kotlinCompilerModule=org.jetbrains.kotlin:kotlin-compiler:1.1-20161229.093306-344
|
||||
|
||||
@@ -15,5 +15,9 @@ internal fun ThrowClassCastException(): Nothing {
|
||||
throw ClassCastException()
|
||||
}
|
||||
|
||||
internal fun ThrowNoWhenBranchMatchedException(): Nothing {
|
||||
throw NoWhenBranchMatchedException()
|
||||
}
|
||||
|
||||
@ExportForCppRuntime
|
||||
internal fun TheEmptyString() = ""
|
||||
@@ -136,4 +136,13 @@ public class AssertionError : Error {
|
||||
|
||||
constructor(message: String, cause: Throwable) : super(message, cause) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class NoWhenBranchMatchedException : RuntimeException {
|
||||
|
||||
constructor() : super() {
|
||||
}
|
||||
|
||||
constructor(s: String) : super(s) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user