diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt index 5cdb7fc9355..e95a6f6f0cb 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt @@ -61,7 +61,7 @@ private class TypeOperatorTransformer(val context: CommonBackendContext, val fun return when (classifier) { is IrClassSymbol -> this is IrTypeParameterSymbol -> { - val upperBound = classifier.owner.superTypes.singleOrNull() ?: + val upperBound = classifier.owner.superTypes.firstOrNull() ?: TODO("${classifier.descriptor} : ${classifier.descriptor.upperBounds}") if (this.hasQuestionMark) { diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 779b1697789..8c3efee1d87 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -574,6 +574,12 @@ task unchecked_cast3(type: RunKonanTest) { source = "codegen/basics/unchecked_cast3.kt" } +task unchecked_cast4(type: RunKonanTest) { + expectedFail = (project.testTarget == 'wasm32') // Uses exceptions. + goldValue = "Ok\n" + source = "codegen/basics/unchecked_cast4.kt" +} + task null_check(type: RunKonanTest) { source = "codegen/basics/null_check.kt" } diff --git a/backend.native/tests/codegen/basics/unchecked_cast4.kt b/backend.native/tests/codegen/basics/unchecked_cast4.kt new file mode 100644 index 00000000000..39b266cdca6 --- /dev/null +++ b/backend.native/tests/codegen/basics/unchecked_cast4.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package codegen.basics.unchecked_cast4 + +import kotlin.test.* + +@Test +fun runTest() { + CI1I2().uncheckedCast() + CI1I2().uncheckedCast() + + assertFailsWith { + Any().uncheckedCast() + } + + println("Ok") +} + +fun Any?.uncheckedCast() where R : I1, R : I2 { + this as R +} + +interface I1 +interface I2 +open class C + +class CI1I2 : C(), I1, I2 +class OtherCI1I2 : C(), I1, I2 \ No newline at end of file