diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt index d9a1e48bd49..364148f6ef1 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt @@ -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 } } diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 232248ede50..cc6eb766176 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -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" } diff --git a/backend.native/tests/codegen/branching/when8.kt b/backend.native/tests/codegen/branching/when8.kt new file mode 100644 index 00000000000..998a421f7cc --- /dev/null +++ b/backend.native/tests/codegen/branching/when8.kt @@ -0,0 +1,6 @@ +fun main(args: Array) { + when (true) { + true -> println("true") + false -> println("false") + } +} diff --git a/gradle.properties b/gradle.properties index 63983f73041..f461d5a1f05 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt b/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt index c7511e3e58b..e0cf2cce35f 100644 --- a/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt +++ b/runtime/src/main/kotlin/konan/internal/RuntimeUtils.kt @@ -15,5 +15,9 @@ internal fun ThrowClassCastException(): Nothing { throw ClassCastException() } +internal fun ThrowNoWhenBranchMatchedException(): Nothing { + throw NoWhenBranchMatchedException() +} + @ExportForCppRuntime internal fun TheEmptyString() = "" \ No newline at end of file diff --git a/runtime/src/main/kotlin/kotlin/Exceptions.kt b/runtime/src/main/kotlin/kotlin/Exceptions.kt index 0effb03329d..75f3c2c32a0 100644 --- a/runtime/src/main/kotlin/kotlin/Exceptions.kt +++ b/runtime/src/main/kotlin/kotlin/Exceptions.kt @@ -136,4 +136,13 @@ public class AssertionError : Error { constructor(message: String, cause: Throwable) : super(message, cause) { } -} \ No newline at end of file +} + +public class NoWhenBranchMatchedException : RuntimeException { + + constructor() : super() { + } + + constructor(s: String) : super(s) { + } +}