diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Exceptions.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Exceptions.kt index c88714a65fd..a9decec4b8e 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Exceptions.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Exceptions.kt @@ -20,3 +20,9 @@ package org.jetbrains.kotlin.backend.konan * Represents a compilation error caused by mistakes in an input file, e.g. undefined reference. */ class KonanCompilationException(message: String = "", cause: Throwable? = null) : Exception(message, cause) {} + +/** + * Internal compiler error: could not deserialize IR for inline function body. + */ +class KonanIrDeserializationException(message: String = "", cause: Throwable? = null) : Exception(message, cause) + diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorDeserializer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorDeserializer.kt index eeea0ba31d7..e93e995bb80 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorDeserializer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorDeserializer.kt @@ -87,6 +87,7 @@ internal class IrDescriptorDeserializer(val context: Context, val text = proto.getDebugText() val typeProto = localDeserializer.typeTable[index] val type = localDeserializer.deserializeInlineType(typeProto) + if (type.isError) throw KonanIrDeserializationException("Could not deserialize KotlinType: $text $type") context.log("### deserialized Kotlin Type index=$index, text=$text:\t$type") return type @@ -111,7 +112,7 @@ internal class IrDescriptorDeserializer(val context: Context, } // TODO // proto.hasClazz() -> - else -> error("Unexpected descriptor kind") + else -> TODO("Unexpected descriptor kind") } } @@ -272,7 +273,7 @@ internal class IrDescriptorDeserializer(val context: Context, newPropertyDescriptor.getter is PropertySetterDescriptor -> newPropertyDescriptor.setter - else -> error("Unexpected accessor kind") + else -> TODO("Unexpected accessor kind") } descriptorIndex.put(proto.index, newDescriptor!!) @@ -312,7 +313,7 @@ internal class IrDescriptorDeserializer(val context: Context, is ClassDescriptor -> parent.getUnsubstitutedMemberScope() is PackageFragmentDescriptor -> parent.getMemberScope() is PackageViewDescriptor -> parent.memberScope - else -> error("could not get a member scope") + else -> TODO("could not get a member scope") } } @@ -450,7 +451,7 @@ internal class IrDescriptorDeserializer(val context: Context, // class descriptors here? //substituteClass(proto, originalDescriptor) originalDescriptor - else -> error("unexpected type of public function") + else -> TODO("unexpected type of public function") } } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/LocalDeclarationDeserializer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/LocalDeclarationDeserializer.kt index 077f792d656..bee84882338 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/LocalDeclarationDeserializer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/LocalDeclarationDeserializer.kt @@ -72,7 +72,7 @@ class LocalDeclarationDeserializer(val rootFunction: FunctionDescriptor, val mod return module.findClassAcrossModuleDependencies(nameResolver.getClassId(fqNameIndex))!! QualifiedName.Kind.PACKAGE -> return module.getPackage(packageName) - else -> error("Unexpected descriptor kind.") + else -> TODO("Unexpected descriptor kind.") } } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt index 59e8913ad26..85f6003dda6 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/SerializeIr.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.backend.konan.Context import org.jetbrains.kotlin.backend.konan.descriptors.getMemberScope import org.jetbrains.kotlin.backend.konan.ir.ir2string import org.jetbrains.kotlin.backend.konan.ir.ir2stringWhole +import org.jetbrains.kotlin.backend.konan.KonanIrDeserializationException import org.jetbrains.kotlin.backend.konan.llvm.base64Decode import org.jetbrains.kotlin.backend.konan.llvm.base64Encode import org.jetbrains.kotlin.descriptors.* @@ -313,7 +314,7 @@ internal class IrSerializer(val context: Context, -> return KonanIr.IrTypeOperator.INSTANCEOF IrTypeOperator.NOT_INSTANCEOF -> return KonanIr.IrTypeOperator.NOT_INSTANCEOF - else -> error("Unknown type operator") + else -> TODO("Unknown type operator") } } @@ -689,7 +690,7 @@ internal class IrDeserializer(val context: Context, IrUnaryPrimitiveImpl(start, end, null, descriptor) KonanIr.IrCall.Primitive.BINARY -> IrBinaryPrimitiveImpl(start, end, null, descriptor) - else -> error("Unexpected primitive IrCall.") + else -> TODO("Unexpected primitive IrCall.") } deserializeMemberAccessCommon(call, proto.memberAccess) return call @@ -802,7 +803,7 @@ internal class IrDeserializer(val context: Context, -> return IrTypeOperator.INSTANCEOF KonanIr.IrTypeOperator.NOT_INSTANCEOF -> return IrTypeOperator.NOT_INSTANCEOF - else -> error("Unknown type operator") + else -> TODO("Unknown type operator") } } @@ -1037,7 +1038,7 @@ internal class IrDeserializer(val context: Context, val proto = (rootFunction as DeserializedSimpleFunctionDescriptor).proto if (!proto.hasExtension(KonanLinkData.inlineIrBody)) { - error("$rootFunction doesn't have ir serialized.") + throw KonanIrDeserializationException("$rootFunction doesn't have ir serialized.") } val inlineProto = proto.getExtension(KonanLinkData.inlineIrBody)