diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt index 3c790483f43..7e5ef1c46f6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/TypeTranslator.kt @@ -164,11 +164,9 @@ abstract class TypeTranslator( return translateType(approximate(commonSupertype.replaceArgumentsWithStarProjections()), variance) } - private fun SimpleType.toIrTypeAbbreviation(): IrTypeAbbreviation { - val typeAliasDescriptor = constructor.declarationDescriptor.let { - it as? TypeAliasDescriptor - ?: throw AssertionError("TypeAliasDescriptor expected: $it") - } + private fun SimpleType.toIrTypeAbbreviation(): IrTypeAbbreviation? { + // Abbreviated type's classifier might not be TypeAliasDescriptor in case it's MockClassDescriptor (not found in dependencies). + val typeAliasDescriptor = constructor.declarationDescriptor as? TypeAliasDescriptor ?: return null return IrTypeAbbreviationImpl( symbolTable.referenceTypeAlias(typeAliasDescriptor), isMarkedNullable, diff --git a/compiler/testData/codegen/box/typealias/kt45308.kt b/compiler/testData/codegen/box/typealias/kt45308.kt index c4ba5d2921c..de507f30575 100644 --- a/compiler/testData/codegen/box/typealias/kt45308.kt +++ b/compiler/testData/codegen/box/typealias/kt45308.kt @@ -1,5 +1,7 @@ -// KT-45308 Psi2ir: "AssertionError: TypeAliasDescriptor expected" caused by using typealias from one module as a type in another module without a transitive dependency -// IGNORE_BACKEND: JVM_IR +// This test checks that unresolved typealias in an abbreviated type does not crash the compiler or result in a compilation error. +// Apparently, there's some demand for this behavior, see KT-45308. + +// FIR reports RETURN_TYPE_MISMATCH: Return type mismatch: expected kotlin/String, actual a/A // IGNORE_BACKEND_FIR: JVM_IR // MODULE: a