~~~ Attempt not to perform array approximation in FIR2IR
diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt
index b6e6722..b28f1a9 100644
--- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt
+++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt
@@ -163,7 +163,14 @@
if (isAlreadyPresentInAnnotations) continue
typeAnnotations += callGenerator.convertToIrConstructorCall(attributeAnnotation) as? IrConstructorCall ?: continue
}
- val approximatedType = type.approximateForIrOrSelf()
+ val approximatedType =
+ if (!type.isArrayTypeOrNullableArrayType || type.typeArguments.any {
+ it.kind != ProjectionKind.INVARIANT || it.type is ConeCapturedType || it.type is ConeIntersectionType
+ }
+ )
+ type.approximateForIrOrSelf()
+ else
+ type
if (approximatedType is ConeTypeParameterType && conversionScope.shouldEraseType(approximatedType)) {
// This hack is about type parameter leak in case of generic delegated property
diff --git a/compiler/testData/codegen/bytecodeText/inaccessibleTypeInArray.kt b/compiler/testData/codegen/bytecodeText/inaccessibleTypeInArray.kt
index 431c9f1..a145a27 100644
--- a/compiler/testData/codegen/bytecodeText/inaccessibleTypeInArray.kt
+++ b/compiler/testData/codegen/bytecodeText/inaccessibleTypeInArray.kt
@@ -33,4 +33,4 @@
foo3()
}
-// 1 INVOKESTATIC test/FooKt.foo1\$default \(\[Lerror/NonExistentClass;ILjava/lang/Object;\)V
+// 0 INVOKESTATIC test/FooKt.foo1\$default \(\[Lerror/NonExistentClass;ILjava/lang/Object;\)V