Fir2Ir, JVM IR: support flexible Array types loaded from Java

We don't have true flexible types in the IR, but we approximate it with
internal type annotations, such as FlexibleNullability,
FlexibleMutability, RawType. These annotations are then handled
specially in JvmIrTypeSystemContext, which can construct a fake flexible
type so that type checker on IR types would behave exactly as on
frontend types.

As shown in KT-63441, one instance of flexible types where flexibility
was lost during conversion to IR is Java array/vararg types. It's
necessary to support it so that IR fake overrides could be constructed
correctly, because IR fake override checker requires parameter types to
be equal. So this change introduces another internal type annotation,
FlexibleArrayElementVariance, which is only applicable to types with
classifier kotlin/Array, and which signifies that the annotated type
`Array<X>` should rather be seen as `Array<X>..Array<out X>`.

 #KT-63441 Fixed
 #KT-63446 Fixed
This commit is contained in:
Alexander Udalov
2023-11-24 16:34:49 +01:00
committed by Space Team
parent e98902ce74
commit ee8d42532b
35 changed files with 571 additions and 48 deletions
@@ -31060,6 +31060,36 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -31060,6 +31060,36 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmen
import org.jetbrains.kotlin.ir.util.createImplicitParameterDeclarationWithWrappedDescriptor import org.jetbrains.kotlin.ir.util.createImplicitParameterDeclarationWithWrappedDescriptor
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.EnhancedNullability import org.jetbrains.kotlin.name.StandardClassIds.Annotations.EnhancedNullability
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.FlexibleArrayElementVariance
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.FlexibleMutability import org.jetbrains.kotlin.name.StandardClassIds.Annotations.FlexibleMutability
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.FlexibleNullability import org.jetbrains.kotlin.name.StandardClassIds.Annotations.FlexibleNullability
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.RawTypeAnnotation import org.jetbrains.kotlin.name.StandardClassIds.Annotations.RawTypeAnnotation
@@ -43,6 +44,7 @@ class Fir2IrJvmSpecialAnnotationSymbolProvider : Fir2IrSpecialSymbolProvider() {
FlexibleNullability -> id.toIrClass(kotlinInternalIrPackage).symbol FlexibleNullability -> id.toIrClass(kotlinInternalIrPackage).symbol
FlexibleMutability -> id.toIrClass(kotlinInternalIrPackage).symbol FlexibleMutability -> id.toIrClass(kotlinInternalIrPackage).symbol
RawTypeAnnotation -> id.toIrClass(kotlinInternalIrPackage).symbol RawTypeAnnotation -> id.toIrClass(kotlinInternalIrPackage).symbol
FlexibleArrayElementVariance -> id.toIrClass(kotlinInternalIrPackage).symbol
else -> null else -> null
} }
@@ -49,6 +49,13 @@ class Fir2IrBuiltIns(
internal fun flexibleMutabilityAnnotationConstructorCall(): IrConstructorCall? = internal fun flexibleMutabilityAnnotationConstructorCall(): IrConstructorCall? =
flexibleMutabilityAnnotationSymbol?.toConstructorCall() flexibleMutabilityAnnotationSymbol?.toConstructorCall()
private val flexibleArrayElementVarianceAnnotationSymbol by lazy {
specialAnnotationIrSymbolById(StandardClassIds.Annotations.FlexibleArrayElementVariance)
}
internal fun flexibleArrayElementVarianceAnnotationConstructorCall(): IrConstructorCall? =
flexibleArrayElementVarianceAnnotationSymbol?.toConstructorCall()
private val rawTypeAnnotationSymbol by lazy { private val rawTypeAnnotationSymbol by lazy {
specialAnnotationIrSymbolById(StandardClassIds.Annotations.RawTypeAnnotation) specialAnnotationIrSymbolById(StandardClassIds.Annotations.RawTypeAnnotation)
} }
@@ -16,14 +16,11 @@ import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.fir.types.impl.*
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.IrTypeArgument
import org.jetbrains.kotlin.ir.types.IrTypeProjection
import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrDynamicTypeImpl
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
import org.jetbrains.kotlin.ir.types.makeNotNull
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.name.StandardClassIds.Annotations.ExtensionFunctionType import org.jetbrains.kotlin.name.StandardClassIds.Annotations.ExtensionFunctionType
@@ -99,6 +96,7 @@ class Fir2IrTypeConverter(
annotations: List<FirAnnotation> = emptyList(), annotations: List<FirAnnotation> = emptyList(),
hasFlexibleNullability: Boolean = false, hasFlexibleNullability: Boolean = false,
hasFlexibleMutability: Boolean = false, hasFlexibleMutability: Boolean = false,
hasFlexibleArrayElementVariance: Boolean = false,
addRawTypeAnnotation: Boolean = false addRawTypeAnnotation: Boolean = false
): IrType { ): IrType {
return when (this) { return when (this) {
@@ -132,6 +130,11 @@ class Fir2IrTypeConverter(
typeAnnotations += it typeAnnotations += it
} }
} }
if (hasFlexibleArrayElementVariance) {
builtIns.flexibleArrayElementVarianceAnnotationConstructorCall()?.let {
typeAnnotations += it
}
}
if (isExtensionFunctionType && annotations.getAnnotationsByClassId(ExtensionFunctionType, session).isEmpty()) { if (isExtensionFunctionType && annotations.getAnnotationsByClassId(ExtensionFunctionType, session).isEmpty()) {
builtIns.extensionFunctionTypeAnnotationConstructorCall()?.let { builtIns.extensionFunctionTypeAnnotationConstructorCall()?.let {
@@ -169,6 +172,7 @@ class Fir2IrTypeConverter(
annotations, annotations,
hasFlexibleNullability = lowerBound.nullability != upperBound.nullability, hasFlexibleNullability = lowerBound.nullability != upperBound.nullability,
hasFlexibleMutability = isMutabilityFlexible(), hasFlexibleMutability = isMutabilityFlexible(),
hasFlexibleArrayElementVariance = false,
addRawTypeAnnotation = true addRawTypeAnnotation = true
) )
} }
@@ -189,14 +193,16 @@ class Fir2IrTypeConverter(
typeOrigin, typeOrigin,
annotations, annotations,
hasFlexibleNullability = lower.nullability != upper.nullability, hasFlexibleNullability = lower.nullability != upper.nullability,
hasFlexibleMutability = isMutabilityFlexible() hasFlexibleMutability = isMutabilityFlexible(),
hasFlexibleArrayElementVariance = hasFlexibleArrayElementVariance(),
) )
} else { } else {
upperBound.toIrType( upperBound.toIrType(
typeOrigin, typeOrigin,
annotations, annotations,
hasFlexibleNullability = lowerBound.nullability != upperBound.nullability, hasFlexibleNullability = lowerBound.nullability != upperBound.nullability,
hasFlexibleMutability = isMutabilityFlexible() hasFlexibleMutability = isMutabilityFlexible(),
hasFlexibleArrayElementVariance = false,
) )
} }
} }
@@ -231,6 +237,15 @@ class Fir2IrTypeConverter(
} }
} }
private fun ConeFlexibleType.hasFlexibleArrayElementVariance(): Boolean =
lowerBound.let { lowerBound ->
lowerBound is ConeClassLikeType && lowerBound.lookupTag.classId == StandardClassIds.Array &&
lowerBound.typeArguments.single().kind == ProjectionKind.INVARIANT
} && upperBound.let { upperBound ->
upperBound is ConeClassLikeType && upperBound.lookupTag.classId == StandardClassIds.Array &&
upperBound.typeArguments.single().kind == ProjectionKind.OUT
}
private fun ConeFlexibleType.isMutabilityFlexible(): Boolean { private fun ConeFlexibleType.isMutabilityFlexible(): Boolean {
val lowerFqName = lowerBound.classId?.asSingleFqName() ?: return false val lowerFqName = lowerBound.classId?.asSingleFqName() ?: return false
val upperFqName = upperBound.classId?.asSingleFqName() ?: return false val upperFqName = upperBound.classId?.asSingleFqName() ?: return false
@@ -30675,6 +30675,36 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -30675,6 +30675,36 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -30675,6 +30675,36 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -1156,6 +1156,9 @@ class JvmSymbols(
val RAW_TYPE_ANNOTATION_FQ_NAME: FqName = val RAW_TYPE_ANNOTATION_FQ_NAME: FqName =
StandardClassIds.Annotations.RawTypeAnnotation.asSingleFqName() StandardClassIds.Annotations.RawTypeAnnotation.asSingleFqName()
val FLEXIBLE_VARIANCE_ANNOTATION_FQ_NAME: FqName =
StandardClassIds.Annotations.FlexibleArrayElementVariance.asSingleFqName()
} }
} }
@@ -6,16 +6,20 @@
package org.jetbrains.kotlin.backend.jvm.ir package org.jetbrains.kotlin.backend.jvm.ir
import org.jetbrains.kotlin.backend.jvm.JvmSymbols import org.jetbrains.kotlin.backend.jvm.JvmSymbols
import org.jetbrains.kotlin.backend.jvm.JvmSymbols.Companion.FLEXIBLE_VARIANCE_ANNOTATION_FQ_NAME
import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.ir.IrBuiltIns import org.jetbrains.kotlin.ir.IrBuiltIns
import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl
import org.jetbrains.kotlin.ir.types.impl.buildSimpleType import org.jetbrains.kotlin.ir.types.impl.buildSimpleType
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable
import org.jetbrains.kotlin.ir.util.hasAnnotation import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.types.FlexibleTypeBoundsChecker import org.jetbrains.kotlin.types.FlexibleTypeBoundsChecker
import org.jetbrains.kotlin.types.Variance
import org.jetbrains.kotlin.types.model.FlexibleTypeMarker import org.jetbrains.kotlin.types.model.FlexibleTypeMarker
internal interface IrJvmFlexibleType : FlexibleTypeMarker { internal interface IrJvmFlexibleType : FlexibleTypeMarker {
@@ -23,13 +27,22 @@ internal interface IrJvmFlexibleType : FlexibleTypeMarker {
val upperBound: IrSimpleType val upperBound: IrSimpleType
} }
/**
* @param arrayVariance used for representing array types loaded from Java.
* Java type `X[]` is loaded in Kotlin as `Array<X!>..Array<out X!>?` (where flexible nullability is handled by [nullability]).
*/
private class IrJvmFlexibleTypeImpl( private class IrJvmFlexibleTypeImpl(
val irType: IrSimpleType, val irType: IrSimpleType,
val builtIns: IrBuiltIns, val builtIns: IrBuiltIns,
val nullability: Boolean, val nullability: Boolean,
val mutability: Boolean, val mutability: Boolean,
val arrayVariance: Boolean,
val raw: Boolean, val raw: Boolean,
) : IrJvmFlexibleType { ) : IrJvmFlexibleType {
init {
check(!arrayVariance || !raw) { "Flexible variance is only possible for Array types, which cannot be raw: ${irType.render()}" }
}
override val lowerBound: IrSimpleType override val lowerBound: IrSimpleType
get() = irType.buildSimpleType { get() = irType.buildSimpleType {
if (this@IrJvmFlexibleTypeImpl.nullability) nullability = SimpleTypeNullability.NOT_SPECIFIED if (this@IrJvmFlexibleTypeImpl.nullability) nullability = SimpleTypeNullability.NOT_SPECIFIED
@@ -52,7 +65,9 @@ private class IrJvmFlexibleTypeImpl(
else -> error("Mutability-flexible type with unknown classifier: ${irType.render()}, FQ name: $readonlyClassFqName") else -> error("Mutability-flexible type with unknown classifier: ${irType.render()}, FQ name: $readonlyClassFqName")
} }
} }
if (arrayVariance) {
arguments = listOf(makeTypeProjection(irType.getArrayElementType(), Variance.INVARIANT))
}
} }
override val upperBound: IrSimpleType override val upperBound: IrSimpleType
@@ -74,11 +89,21 @@ private class IrJvmFlexibleTypeImpl(
else -> error("Mutability-flexible type with unknown classifier: ${irType.render()}, FQ name: $readonlyClassFqName") else -> error("Mutability-flexible type with unknown classifier: ${irType.render()}, FQ name: $readonlyClassFqName")
} }
} }
if (arrayVariance) {
arguments = listOf(makeTypeProjection(irType.getArrayElementType(), Variance.OUT_VARIANCE))
}
if (raw) { if (raw) {
arguments = List(arguments.size) { IrStarProjectionImpl } arguments = List(arguments.size) { IrStarProjectionImpl }
} }
kotlinType = null kotlinType = null
} }
private fun IrSimpleType.getArrayElementType(): IrType =
when (val argument = arguments.singleOrNull()) {
is IrTypeProjection -> argument.type
is IrStarProjection -> error("Star projection is not possible for the argument of Array type: ${irType.render()}")
null -> error("Flexible variance is only possible for Array types: ${irType.render()}")
}
} }
fun IrType.isWithFlexibleNullability(): Boolean = fun IrType.isWithFlexibleNullability(): Boolean =
@@ -87,20 +112,25 @@ fun IrType.isWithFlexibleNullability(): Boolean =
internal fun IrType.isWithFlexibleMutability(): Boolean = internal fun IrType.isWithFlexibleMutability(): Boolean =
hasAnnotation(JvmSymbols.FLEXIBLE_MUTABILITY_ANNOTATION_FQ_NAME) hasAnnotation(JvmSymbols.FLEXIBLE_MUTABILITY_ANNOTATION_FQ_NAME)
private fun IrType.isWithFlexibleVariance(): Boolean =
hasAnnotation(StandardClassIds.Annotations.FlexibleArrayElementVariance)
internal fun IrType.asJvmFlexibleType(builtIns: IrBuiltIns): FlexibleTypeMarker? { internal fun IrType.asJvmFlexibleType(builtIns: IrBuiltIns): FlexibleTypeMarker? {
if (this !is IrSimpleType || annotations.isEmpty()) return null if (this !is IrSimpleType || annotations.isEmpty()) return null
val nullability = isWithFlexibleNullability() val nullability = isWithFlexibleNullability()
val mutability = isWithFlexibleMutability() val mutability = isWithFlexibleMutability()
val flexibleVariance = isWithFlexibleVariance()
val raw = isRawType() val raw = isRawType()
if (!nullability && !mutability && !raw) return null if (!nullability && !mutability && !flexibleVariance && !raw) return null
val baseType = this.removeAnnotations { irCtorCall -> val baseType = this.removeAnnotations { irCtorCall ->
val fqName = irCtorCall.type.classFqName val fqName = irCtorCall.type.classFqName
fqName == JvmSymbols.FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME || fqName == JvmSymbols.FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME ||
fqName == JvmSymbols.FLEXIBLE_MUTABILITY_ANNOTATION_FQ_NAME || fqName == JvmSymbols.FLEXIBLE_MUTABILITY_ANNOTATION_FQ_NAME ||
fqName == FLEXIBLE_VARIANCE_ANNOTATION_FQ_NAME ||
fqName == JvmSymbols.RAW_TYPE_ANNOTATION_FQ_NAME fqName == JvmSymbols.RAW_TYPE_ANNOTATION_FQ_NAME
} as IrSimpleType } as IrSimpleType
return IrJvmFlexibleTypeImpl(baseType, builtIns, nullability, mutability, raw) return IrJvmFlexibleTypeImpl(baseType, builtIns, nullability, mutability, flexibleVariance, raw)
} }
@@ -106,7 +106,7 @@ class CopyIrTreeWithSymbolsForFakeOverrides(
} }
private companion object { private companion object {
// TODO: RawTypeAnnotation, FlexibleMutability, EnhancedNullability? // TODO (KT-64715): RawTypeAnnotation, FlexibleMutability, EnhancedNullability, RawType, FlexibleArrayElementVariance?
val TYPE_ANNOTATIONS_TO_MERGE = listOf( val TYPE_ANNOTATIONS_TO_MERGE = listOf(
FlexibleNullability.asSingleFqName(), FlexibleNullability.asSingleFqName(),
) )
@@ -88,8 +88,8 @@ FILE fqName:<root> fileName:/test.kt
$receiver: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.map, R of kotlin.collections.map>): kotlin.collections.List<R of kotlin.collections.map> declared in kotlin.collections' type=kotlin.collections.List<kotlin.String> origin=null $receiver: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.map, R of kotlin.collections.map>): kotlin.collections.List<R of kotlin.collections.map> declared in kotlin.collections' type=kotlin.collections.List<kotlin.String> origin=null
<T>: @[FlexibleNullability] kotlin.Annotation? <T>: @[FlexibleNullability] kotlin.Annotation?
<R>: kotlin.String <R>: kotlin.String
$receiver: TYPE_OP type=kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> $receiver: TYPE_OP type=@[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>
CALL 'public open fun getAnnotations (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Field' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY CALL 'public open fun getAnnotations (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Field' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY
$this: CALL 'public open fun getDeclaredField (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.reflect.Field? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Field? origin=null $this: CALL 'public open fun getDeclaredField (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.reflect.Field? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Field? origin=null
$this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<<root>.Foo> origin=GET_PROPERTY $this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<<root>.Foo> origin=GET_PROPERTY
<T>: <root>.Foo <T>: <root>.Foo
@@ -247,8 +247,8 @@ FILE fqName:<root> fileName:/targetOnPrimaryCtorParameter.kt
$receiver: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.map, R of kotlin.collections.map>): kotlin.collections.List<R of kotlin.collections.map> declared in kotlin.collections' type=kotlin.collections.List<kotlin.String> origin=null $receiver: CALL 'public final fun map <T, R> (transform: kotlin.Function1<T of kotlin.collections.map, R of kotlin.collections.map>): kotlin.collections.List<R of kotlin.collections.map> declared in kotlin.collections' type=kotlin.collections.List<kotlin.String> origin=null
<T>: @[FlexibleNullability] kotlin.Annotation? <T>: @[FlexibleNullability] kotlin.Annotation?
<R>: kotlin.String <R>: kotlin.String
$receiver: TYPE_OP type=kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> $receiver: TYPE_OP type=@[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?> origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>
CALL 'public open fun getAnnotations (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Field' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY CALL 'public open fun getAnnotations (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Field' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY
$this: CALL 'public open fun getDeclaredField (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.reflect.Field? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Field? origin=null $this: CALL 'public open fun getDeclaredField (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] java.lang.reflect.Field? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Field? origin=null
$this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<<root>.Foo> origin=GET_PROPERTY $this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<<root>.Foo> origin=GET_PROPERTY
<T>: <root>.Foo <T>: <root>.Foo
@@ -0,0 +1,37 @@
// TARGET_BACKEND: JVM
// FILE: J.java
interface J {
String foo(String[] a);
}
// FILE: 1.kt
class Inv : J {
override fun foo(a: Array<String>): String = a[0]
}
class Out : J {
override fun foo(a: Array<out String>): String = a[0]
}
class Vararg : J {
override fun foo(vararg a: String): String = a[0]
}
class InvNullableElement : J {
override fun foo(a: Array<String?>): String = a[0] ?: "Fail"
}
class InvNullableArray : J {
override fun foo(a: Array<String>?): String = a?.get(0) ?: "Fail"
}
fun box(): String {
if (Inv().foo(arrayOf("OK")) != "OK") return "Fail Inv"
if (Out().foo(arrayOf("OK")) != "OK") return "Fail Out"
if (Vararg().foo("OK") != "OK") return "Fail Vararg"
if (InvNullableElement().foo(arrayOf("OK")) != "OK") return "Fail InvNullableElement"
if (InvNullableArray().foo(arrayOf("OK")) != "OK") return "Fail InvNullableArray"
return "OK"
}
@@ -0,0 +1,41 @@
// TARGET_BACKEND: JVM
// FILE: J.java
import java.util.List;
// This is a bit more elaborate version of overrideWithArrayParameterType.kt, which also checks interaction of:
// flexible nullability, flexible mutability, raw types, varargs.
interface J {
List<String>[] foo(List... a);
}
// FILE: 1.kt
class C1 : J {
override fun foo(vararg a: MutableList<Any?>?): Array<out MutableList<String>>? = null
}
class C2 : J {
override fun foo(vararg a: List<Any?>): Array<MutableList<out String>>? = null
}
class C3 : J {
override fun foo(vararg a: List<*>): Array<List<String>?>? = null
}
class C4 : J {
override fun foo(vararg a: MutableList<out Any?>): Array<out List<String?>>? = null
}
class C5 : J {
override fun foo(a: Array<List<Any?>>): Array<MutableList<String>>? = null
}
class C6 : J {
override fun foo(a: Array<out MutableList<Any?>?>): Array<out MutableList<String>>? = null
}
fun box(): String {
C1().foo()
C2().foo()
C3().foo()
C4().foo()
C5().foo(emptyArray())
C6().foo(emptyArray())
return "OK"
}
@@ -0,0 +1,34 @@
// TARGET_BACKEND: JVM
// FILE: J.java
import org.jetbrains.annotations.NotNull;
interface J {
String foo(@NotNull String[] a);
}
// FILE: 1.kt
class Inv : J {
override fun foo(a: Array<String>): String = a[0]
}
class Out : J {
override fun foo(a: Array<out String>): String = a[0]
}
class Vararg : J {
override fun foo(vararg a: String): String = a[0]
}
class InvNullableElement : J {
override fun foo(a: Array<String?>): String = a[0] ?: "Fail"
}
fun box(): String {
if (Inv().foo(arrayOf("OK")) != "OK") return "Fail Inv"
if (Out().foo(arrayOf("OK")) != "OK") return "Fail Out"
if (Vararg().foo("OK") != "OK") return "Fail Vararg"
if (InvNullableElement().foo(arrayOf("OK")) != "OK") return "Fail InvNullableElement"
return "OK"
}
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM
// FILE: J.java
import java.util.List;
public interface J<T> {
String foo(T t, List<T[]> list);
}
// FILE: 1.kt
class A
class C : J<A> {
override fun foo(a: A, list: List<Array<A>>?): String = "OK"
}
fun box(): String {
val c: J<A> = C()
return c.foo(A(), null)
}
@@ -0,0 +1,27 @@
// TARGET_BACKEND: JVM
// FILE: J.java
interface J {
String foo(String... a);
}
// FILE: 1.kt
class Inv : J {
override fun foo(a: Array<String>): String = a[0]
}
class Out : J {
override fun foo(a: Array<out String>): String = a[0]
}
class Vararg : J {
override fun foo(vararg a: String): String = a[0]
}
fun box(): String {
if (Inv().foo(arrayOf("OK")) != "OK") return "Fail Inv"
if (Out().foo(arrayOf("OK")) != "OK") return "Fail Out"
if (Vararg().foo("OK") != "OK") return "Fail Vararg"
return "OK"
}
@@ -46,16 +46,16 @@ FILE fqName:<root> fileName:/ArrayListOverrides.kt
overridden: overridden:
public open fun clone (): @[EnhancedNullability] kotlin.Any declared in java.util.ArrayList public open fun clone (): @[EnhancedNullability] kotlin.Any declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override]
overridden: overridden:
public open fun toArray (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in java.util.ArrayList public open fun toArray (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<kotlin.String>, p0:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.A1.toArray?>?) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.A1.toArray?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<kotlin.String>, p0:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.A1.toArray?>?) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.A1.toArray?>? [fake_override]
overridden: overridden:
public open fun toArray <T> (p0: @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>?): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>? declared in java.util.ArrayList public open fun toArray <T> (p0: @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>?): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>? declared in java.util.ArrayList
TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String>
VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.A1.toArray?>? VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.A1.toArray?>?
FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>, p0:kotlin.Int) returnType:@[EnhancedNullability] kotlin.String [fake_override,operator] FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>, p0:kotlin.Int) returnType:@[EnhancedNullability] kotlin.String [fake_override,operator]
overridden: overridden:
public open fun get (p0: kotlin.Int): @[EnhancedNullability] E of java.util.ArrayList declared in java.util.ArrayList public open fun get (p0: kotlin.Int): @[EnhancedNullability] E of java.util.ArrayList declared in java.util.ArrayList
@@ -243,16 +243,16 @@ FILE fqName:<root> fileName:/ArrayListOverrides.kt
overridden: overridden:
public open fun clone (): @[EnhancedNullability] kotlin.Any declared in java.util.ArrayList public open fun clone (): @[EnhancedNullability] kotlin.Any declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override]
overridden: overridden:
public open fun toArray (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in java.util.ArrayList public open fun toArray (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<kotlin.String>, p0:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.A2.toArray?>?) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.A2.toArray?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<kotlin.String>, p0:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.A2.toArray?>?) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.A2.toArray?>? [fake_override]
overridden: overridden:
public open fun toArray <T> (p0: @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>?): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>? declared in java.util.ArrayList public open fun toArray <T> (p0: @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>?): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>? declared in java.util.ArrayList
TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<kotlin.String>
VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.A2.toArray?>? VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.A2.toArray?>?
FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>, p0:kotlin.Int) returnType:@[EnhancedNullability] kotlin.String [fake_override,operator] FUN FAKE_OVERRIDE name:get visibility:public modality:OPEN <> ($this:java.util.ArrayList<kotlin.String>, p0:kotlin.Int) returnType:@[EnhancedNullability] kotlin.String [fake_override,operator]
overridden: overridden:
public open fun get (p0: kotlin.Int): @[EnhancedNullability] E of java.util.ArrayList declared in java.util.ArrayList public open fun get (p0: kotlin.Int): @[EnhancedNullability] E of java.util.ArrayList declared in java.util.ArrayList
+10 -10
View File
@@ -252,16 +252,16 @@ FILE fqName:<root> fileName:/MultiList.kt
overridden: overridden:
public open fun <get-size> (): kotlin.Int declared in java.util.ArrayList public open fun <get-size> (): kotlin.Int declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<T of <root>.SomeList>> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override]
overridden: overridden:
public open fun toArray (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in java.util.ArrayList public open fun toArray (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in java.util.ArrayList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<T of <root>.SomeList>> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>, p0:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>?) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>, p0:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>?) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>? [fake_override]
overridden: overridden:
public open fun toArray <T> (p0: @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>?): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>? declared in java.util.ArrayList public open fun toArray <T> (p0: @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>?): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of java.util.ArrayList.toArray?>? declared in java.util.ArrayList
TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<T of <root>.SomeList>> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>
VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>? VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>?
FUN FAKE_OVERRIDE name:add visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>, p0:@[EnhancedNullability] <root>.Some<T of <root>.SomeList>) returnType:kotlin.Boolean [fake_override] FUN FAKE_OVERRIDE name:add visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<T of <root>.SomeList>>, p0:@[EnhancedNullability] <root>.Some<T of <root>.SomeList>) returnType:kotlin.Boolean [fake_override]
overridden: overridden:
public open fun add (p0: @[EnhancedNullability] E of java.util.ArrayList): kotlin.Boolean declared in java.util.ArrayList public open fun add (p0: @[EnhancedNullability] E of java.util.ArrayList): kotlin.Boolean declared in java.util.ArrayList
@@ -441,16 +441,16 @@ FILE fqName:<root> fileName:/MultiList.kt
overridden: overridden:
public open fun <get-size> (): kotlin.Int declared in <root>.SomeList public open fun <get-size> (): kotlin.Int declared in <root>.SomeList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<kotlin.String>> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<kotlin.String>>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<kotlin.String>>) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<kotlin.String>>) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? [fake_override]
overridden: overridden:
public open fun toArray (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in <root>.SomeList public open fun toArray (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? declared in <root>.SomeList
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<kotlin.String>> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<kotlin.String>>
FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<<root>.Some<kotlin.String>>, p0:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.FinalList.toArray?>?) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.FinalList.toArray?>? [fake_override] FUN FAKE_OVERRIDE name:toArray visibility:public modality:OPEN <T> ($this:java.util.ArrayList<<root>.Some<kotlin.String>>, p0:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.FinalList.toArray?>?) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.FinalList.toArray?>? [fake_override]
overridden: overridden:
public open fun toArray <T> (p0: @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>?): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>? declared in <root>.SomeList public open fun toArray <T> (p0: @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>?): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.SomeList.toArray?>? declared in <root>.SomeList
TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false TYPE_PARAMETER name:T index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] reified:false
$this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<kotlin.String>> $this: VALUE_PARAMETER name:<this> type:java.util.ArrayList<<root>.Some<kotlin.String>>
VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] T of <root>.FinalList.toArray?>? VALUE_PARAMETER name:p0 index:0 type:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] T of <root>.FinalList.toArray?>?
FUN FAKE_OVERRIDE name:add visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<kotlin.String>>, p0:@[EnhancedNullability] <root>.Some<kotlin.String>) returnType:kotlin.Boolean [fake_override] FUN FAKE_OVERRIDE name:add visibility:public modality:OPEN <> ($this:java.util.ArrayList<<root>.Some<kotlin.String>>, p0:@[EnhancedNullability] <root>.Some<kotlin.String>) returnType:kotlin.Boolean [fake_override]
overridden: overridden:
public open fun add (p0: @[EnhancedNullability] <root>.Some<T of <root>.SomeList>): kotlin.Boolean declared in <root>.SomeList public open fun add (p0: @[EnhancedNullability] <root>.Some<T of <root>.SomeList>): kotlin.Boolean declared in <root>.SomeList
@@ -36,18 +36,18 @@ FILE fqName:<root> fileName:/reflectFindAnnotationOnDefaultMethodParameter.kt
<T>: <root>.box.<no name provided> <T>: <root>.box.<no name provided>
$receiver: GET_VAR 'val impl: <root>.box.<no name provided> declared in <root>.box' type=<root>.box.<no name provided> origin=null $receiver: GET_VAR 'val impl: <root>.box.<no name provided> declared in <root>.box' type=<root>.box.<no name provided> origin=null
p0: CONST String type=kotlin.String value="m" p0: CONST String type=kotlin.String value="m"
p1: VARARG type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.Class<*>?>? varargElementType=@[FlexibleNullability] java.lang.Class<*>? p1: VARARG type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.Class<*>?>? varargElementType=@[FlexibleNullability] java.lang.Class<*>?
CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<kotlin.String> origin=GET_PROPERTY CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<kotlin.String> origin=GET_PROPERTY
<T>: kotlin.String <T>: kotlin.String
$receiver: CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:String modality:FINAL visibility:public superTypes:[kotlin.Comparable<kotlin.String>; kotlin.CharSequence; java.io.Serializable]' type=kotlin.reflect.KClass<kotlin.String> $receiver: CLASS_REFERENCE 'CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:String modality:FINAL visibility:public superTypes:[kotlin.Comparable<kotlin.String>; kotlin.CharSequence; java.io.Serializable]' type=kotlin.reflect.KClass<kotlin.String>
VAR name:parameter type:@[FlexibleNullability] java.lang.reflect.Parameter? [val] VAR name:parameter type:@[FlexibleNullability] java.lang.reflect.Parameter? [val]
CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array declared in kotlin.Array' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null
$this: CALL 'public open fun getParameters (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? origin=GET_PROPERTY $this: CALL 'public open fun getParameters (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? declared in java.lang.reflect.Method' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Parameter?>? origin=GET_PROPERTY
$this: GET_VAR 'val method: @[FlexibleNullability] java.lang.reflect.Method? declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: GET_VAR 'val method: @[FlexibleNullability] java.lang.reflect.Method? declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null
index: CONST Int type=kotlin.Int value=0 index: CONST Int type=kotlin.Int value=0
VAR name:size type:kotlin.Int [val] VAR name:size type:kotlin.Int [val]
CALL 'public final fun <get-size> (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY CALL 'public final fun <get-size> (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY
$this: CALL 'public open fun getAnnotations (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Parameter' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY $this: CALL 'public open fun getAnnotations (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? declared in java.lang.reflect.Parameter' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Annotation?>? origin=GET_PROPERTY
$this: GET_VAR 'val parameter: @[FlexibleNullability] java.lang.reflect.Parameter? declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null $this: GET_VAR 'val parameter: @[FlexibleNullability] java.lang.reflect.Parameter? declared in <root>.box' type=@[FlexibleNullability] java.lang.reflect.Parameter? origin=null
WHEN type=kotlin.Unit origin=IF WHEN type=kotlin.Unit origin=IF
BRANCH BRANCH
@@ -0,0 +1,8 @@
FILE fqName:<root> fileName:/throwableStackTrace.kt
FUN name:foo visibility:public modality:FINAL <> (t:kotlin.Throwable) returnType:kotlin.Unit
VALUE_PARAMETER name:t index:0 type:kotlin.Throwable
BLOCK_BODY
CALL 'public open fun setStackTrace (p0: @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.StackTraceElement?>?): kotlin.Unit declared in kotlin.Throwable' type=kotlin.Unit origin=EQ
$this: GET_VAR 't: kotlin.Throwable declared in <root>.foo' type=kotlin.Throwable origin=null
p0: CALL 'public open fun getStackTrace (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.StackTraceElement?>? declared in kotlin.Throwable' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.StackTraceElement?>? origin=GET_PROPERTY
$this: GET_VAR 't: kotlin.Throwable declared in <root>.foo' type=kotlin.Throwable origin=null
@@ -0,0 +1,3 @@
fun foo(t: Throwable) {
t.setStackTrace(p0 = t.getStackTrace())
}
@@ -1,5 +1,4 @@
// TARGET_BACKEND: JVM // TARGET_BACKEND: JVM
// FIR_IDENTICAL
// WITH_STDLIB // WITH_STDLIB
// FULL_JDK // FULL_JDK
@@ -1,9 +1,9 @@
FILE fqName:<root> fileName:/jdkClassSyntheticProperty.kt FILE fqName:<root> fileName:/jdkClassSyntheticProperty.kt
PROPERTY name:test visibility:public modality:FINAL [val] PROPERTY name:test visibility:public modality:FINAL [val]
FUN name:<get-test> visibility:public modality:FINAL <> ($receiver:java.lang.Class<*>) returnType:@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? FUN name:<get-test> visibility:public modality:FINAL <> ($receiver:java.lang.Class<*>) returnType:@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>?
correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val] correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val]
$receiver: VALUE_PARAMETER name:<this> type:java.lang.Class<*> $receiver: VALUE_PARAMETER name:<this> type:java.lang.Class<*>
BLOCK_BODY BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-test> (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in <root>' RETURN type=kotlin.Nothing from='public final fun <get-test> (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in <root>'
CALL 'public open fun getDeclaredFields (): @[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in java.lang.Class' type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? origin=GET_PROPERTY CALL 'public open fun getDeclaredFields (): @[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? declared in java.lang.Class' type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] java.lang.reflect.Field?>? origin=GET_PROPERTY
$this: GET_VAR '<this>: java.lang.Class<*> declared in <root>.<get-test>' type=java.lang.Class<*> origin=null $this: GET_VAR '<this>: java.lang.Class<*> declared in <root>.<get-test>' type=java.lang.Class<*> origin=null
@@ -1,4 +1,4 @@
val Class<*>.test: @FlexibleNullability Array<out @FlexibleNullability Field?>? val Class<*>.test: @FlexibleNullability @FlexibleArrayElementVariance Array<out @FlexibleNullability Field?>?
get(): @FlexibleNullability Array<out @FlexibleNullability Field?>? { get(): @FlexibleNullability @FlexibleArrayElementVariance Array<out @FlexibleNullability Field?>? {
return <this>.getDeclaredFields() return <this>.getDeclaredFields()
} }
@@ -57,7 +57,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
BLOCK type=kotlin.Unit origin=FOR_LOOP BLOCK type=kotlin.Unit origin=FOR_LOOP
VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> [val] VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> [val]
CALL 'public final fun iterator (): kotlin.collections.Iterator<T of kotlin.Array> declared in kotlin.Array' type=kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> origin=FOR_LOOP_ITERATOR CALL 'public final fun iterator (): kotlin.collections.Iterator<T of kotlin.Array> declared in kotlin.Array' type=kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> origin=FOR_LOOP_ITERATOR
$this: CALL 'public open fun arrayOfNotNull (): @[EnhancedNullability] kotlin.Array<out @[EnhancedNullability] <root>.P> declared in <root>.J' type=@[EnhancedNullability] kotlin.Array<out @[EnhancedNullability] <root>.P> origin=null $this: CALL 'public open fun arrayOfNotNull (): @[EnhancedNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[EnhancedNullability] <root>.P> declared in <root>.J' type=@[EnhancedNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[EnhancedNullability] <root>.P> origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.testForInArrayUnused' type=<root>.J origin=null $this: GET_VAR 'j: <root>.J declared in <root>.testForInArrayUnused' type=<root>.J origin=null
WHILE label=null origin=FOR_LOOP_INNER_WHILE WHILE label=null origin=FOR_LOOP_INNER_WHILE
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
@@ -93,7 +93,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInForLoop.kt
BLOCK type=kotlin.Unit origin=FOR_LOOP BLOCK type=kotlin.Unit origin=FOR_LOOP
VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> [val] VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> [val]
CALL 'public final fun iterator (): kotlin.collections.Iterator<T of kotlin.Array> declared in kotlin.Array' type=kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> origin=FOR_LOOP_ITERATOR CALL 'public final fun iterator (): kotlin.collections.Iterator<T of kotlin.Array> declared in kotlin.Array' type=kotlin.collections.Iterator<@[EnhancedNullability] <root>.P> origin=FOR_LOOP_ITERATOR
$this: CALL 'public open fun arrayOfNotNull (): @[EnhancedNullability] kotlin.Array<out @[EnhancedNullability] <root>.P> declared in <root>.J' type=@[EnhancedNullability] kotlin.Array<out @[EnhancedNullability] <root>.P> origin=null $this: CALL 'public open fun arrayOfNotNull (): @[EnhancedNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[EnhancedNullability] <root>.P> declared in <root>.J' type=@[EnhancedNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[EnhancedNullability] <root>.P> origin=null
$this: GET_VAR 'j: <root>.J declared in <root>.testForInArrayUse' type=<root>.J origin=null $this: GET_VAR 'j: <root>.J declared in <root>.testForInArrayUse' type=<root>.J origin=null
WHILE label=null origin=FOR_LOOP_INNER_WHILE WHILE label=null origin=FOR_LOOP_INNER_WHILE
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
@@ -30675,6 +30675,36 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -28965,6 +28965,36 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -30675,6 +30675,36 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -30675,6 +30675,36 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@Test
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@Test
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@Test
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@Test
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@Test @Test
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
@@ -6,7 +6,6 @@
package org.jetbrains.kotlin.test.backend.handlers package org.jetbrains.kotlin.test.backend.handlers
import com.intellij.rt.execution.junit.FileComparisonFailure import com.intellij.rt.execution.junit.FileComparisonFailure
import org.jetbrains.kotlin.ir.util.parents
import org.jetbrains.kotlin.backend.common.serialization.signature.PublicIdSignatureComputer import org.jetbrains.kotlin.backend.common.serialization.signature.PublicIdSignatureComputer
import org.jetbrains.kotlin.backend.jvm.JvmSymbols import org.jetbrains.kotlin.backend.jvm.JvmSymbols
import org.jetbrains.kotlin.backend.jvm.ir.hasPlatformDependent import org.jetbrains.kotlin.backend.jvm.ir.hasPlatformDependent
@@ -349,6 +348,7 @@ private val EXCLUDED_ANNOTATIONS = setOf(
StandardNames.FqNames.parameterName, StandardNames.FqNames.parameterName,
JvmSymbols.FLEXIBLE_MUTABILITY_ANNOTATION_FQ_NAME, JvmSymbols.FLEXIBLE_MUTABILITY_ANNOTATION_FQ_NAME,
JvmSymbols.FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME, JvmSymbols.FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME,
JvmSymbols.FLEXIBLE_VARIANCE_ANNOTATION_FQ_NAME,
JvmSymbols.RAW_TYPE_ANNOTATION_FQ_NAME, JvmSymbols.RAW_TYPE_ANNOTATION_FQ_NAME,
StandardClassIds.Annotations.ContextFunctionTypeParams.asSingleFqName(), StandardClassIds.Annotations.ContextFunctionTypeParams.asSingleFqName(),
JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION, JvmAnnotationNames.JETBRAINS_NOT_NULL_ANNOTATION,
@@ -25961,6 +25961,31 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt"); runTest("compiler/testData/codegen/box/javaInterop/notFoundClasses.kt");
} }
@TestMetadata("overrideWithArrayParameterType.kt")
public void testOverrideWithArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType.kt");
}
@TestMetadata("overrideWithArrayParameterType2.kt")
public void testOverrideWithArrayParameterType2() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterType2.kt");
}
@TestMetadata("overrideWithArrayParameterTypeNotNull.kt")
public void testOverrideWithArrayParameterTypeNotNull() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithArrayParameterTypeNotNull.kt");
}
@TestMetadata("overrideWithGenericArrayParameterType.kt")
public void testOverrideWithGenericArrayParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithGenericArrayParameterType.kt");
}
@TestMetadata("overrideWithVarargParameterType.kt")
public void testOverrideWithVarargParameterType() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/overrideWithVarargParameterType.kt");
}
@TestMetadata("protectedField.kt") @TestMetadata("protectedField.kt")
public void testProtectedField() throws Exception { public void testProtectedField() throws Exception {
runTest("compiler/testData/codegen/box/javaInterop/protectedField.kt"); runTest("compiler/testData/codegen/box/javaInterop/protectedField.kt");
@@ -175,6 +175,7 @@ object StandardClassIds {
val RawTypeAnnotation = "RawType".internalIrId() val RawTypeAnnotation = "RawType".internalIrId()
val FlexibleNullability = "FlexibleNullability".internalIrId() val FlexibleNullability = "FlexibleNullability".internalIrId()
val FlexibleMutability = "FlexibleMutability".internalIrId() val FlexibleMutability = "FlexibleMutability".internalIrId()
val FlexibleArrayElementVariance = "FlexibleArrayElementVariance".internalIrId()
val EnhancedNullability = "EnhancedNullability".jvmInternalId() val EnhancedNullability = "EnhancedNullability".jvmInternalId()
val FunctionN = "FunctionN".jvmFunctionsId() val FunctionN = "FunctionN".jvmFunctionsId()
@@ -227,7 +227,7 @@ FILE fqName:<root> fileName:/main.kt
VAR name:derived type:@[FlexibleNullability] <root>.Derived? [val] VAR name:derived type:@[FlexibleNullability] <root>.Derived? [val]
CALL 'public open fun newInstance (vararg p0: @[FlexibleNullability] kotlin.Any?): @[FlexibleNullability] T of java.lang.reflect.Constructor? declared in java.lang.reflect.Constructor' type=@[FlexibleNullability] <root>.Derived? origin=null CALL 'public open fun newInstance (vararg p0: @[FlexibleNullability] kotlin.Any?): @[FlexibleNullability] T of java.lang.reflect.Constructor? declared in java.lang.reflect.Constructor' type=@[FlexibleNullability] <root>.Derived? origin=null
$this: GET_VAR 'val constructor: java.lang.reflect.Constructor<<root>.Derived> declared in <root>.box' type=java.lang.reflect.Constructor<<root>.Derived> origin=null $this: GET_VAR 'val constructor: java.lang.reflect.Constructor<<root>.Derived> declared in <root>.box' type=java.lang.reflect.Constructor<<root>.Derived> origin=null
p0: VARARG type=@[FlexibleNullability] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? varargElementType=@[FlexibleNullability] kotlin.Any? p0: VARARG type=@[FlexibleNullability] @[FlexibleArrayElementVariance] kotlin.Array<out @[FlexibleNullability] kotlin.Any?>? varargElementType=@[FlexibleNullability] kotlin.Any?
CONSTRUCTOR_CALL 'public constructor <init> (s: kotlin.String) declared in <root>.A' type=<root>.A origin=null CONSTRUCTOR_CALL 'public constructor <init> (s: kotlin.String) declared in <root>.A' type=<root>.A origin=null
s: CONST String type=kotlin.String value="a" s: CONST String type=kotlin.String value="a"
CONSTRUCTOR_CALL 'public constructor <init> (s: kotlin.String) declared in <root>.B' type=<root>.B origin=null CONSTRUCTOR_CALL 'public constructor <init> (s: kotlin.String) declared in <root>.B' type=<root>.B origin=null