diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index c4218597a85..95ff46af544 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -96,6 +96,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/classes/delegatedImplementation.kt"); } + @TestMetadata("delegatedImplementationOfJavaInterface.kt") + public void testDelegatedImplementationOfJavaInterface() throws Exception { + runTest("compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt"); + } + @TestMetadata("delegatedImplementationWithExplicitOverride.kt") public void testDelegatedImplementationWithExplicitOverride() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.kt"); diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt index dc3fc9fb9ae..8021a4f4e7b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmGeneratorExtensions.kt @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.jvm import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor import org.jetbrains.kotlin.backend.common.ir.createParameterDeclarations -import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.codegen.SamType import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.FilteredAnnotations @@ -19,6 +18,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrFactory import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl +import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.symbols.impl.DescriptorlessExternalPackageFragmentSymbol import org.jetbrains.kotlin.ir.util.constructors import org.jetbrains.kotlin.load.java.JvmAnnotationNames @@ -28,6 +28,7 @@ import org.jetbrains.kotlin.load.java.descriptors.getParentJavaStaticClassScope import org.jetbrains.kotlin.load.java.sam.JavaSingleAbstractMethodUtils import org.jetbrains.kotlin.load.java.typeEnhancement.hasEnhancedNullability import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi2ir.generators.GeneratorExtensions import org.jetbrains.kotlin.resolve.jvm.JvmClassName @@ -105,24 +106,45 @@ class JvmGeneratorExtensions(private val generateFacades: Boolean = true) : Gene override fun getParentClassStaticScope(descriptor: ClassDescriptor): MemberScope? = descriptor.getParentJavaStaticClassScope() - private val annotationPackage = - IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), StandardNames.ANNOTATION_PACKAGE_FQ_NAME) + private val kotlinIrInternalPackage = + IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), IrBuiltIns.KOTLIN_INTERNAL_IR_FQN) + + private val kotlinJvmInternalPackage = + IrExternalPackageFragmentImpl(DescriptorlessExternalPackageFragmentSymbol(), JvmAnnotationNames.KOTLIN_JVM_INTERNAL) private val flexibleNullabilityAnnotationClass = IrFactoryImpl.buildClass { kind = ClassKind.ANNOTATION_CLASS name = FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME.shortName() }.apply { createImplicitParameterDeclarationWithWrappedDescriptor() - parent = annotationPackage + parent = kotlinIrInternalPackage addConstructor { isPrimary = true } } - override val flexibleNullabilityAnnotationConstructor: IrConstructor? = flexibleNullabilityAnnotationClass.constructors.single() + private val enhancedNullabilityAnnotationClass = IrFactoryImpl.buildClass { + kind = ClassKind.ANNOTATION_CLASS + name = ENHANCED_NULLABILITY_ANNOTATION_FQ_NAME.shortName() + }.apply { + createImplicitParameterDeclarationWithWrappedDescriptor() + parent = kotlinJvmInternalPackage + addConstructor { + isPrimary = true + } + } + + override val flexibleNullabilityAnnotationConstructor: IrConstructor? = + flexibleNullabilityAnnotationClass.constructors.single() + + override val enhancedNullabilityAnnotationConstructor: IrConstructor? = + enhancedNullabilityAnnotationClass.constructors.single() companion object { val FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME = - StandardNames.ANNOTATION_PACKAGE_FQ_NAME.child(Name.identifier("FlexibleNullability")) + IrBuiltIns.KOTLIN_INTERNAL_IR_FQN.child(Name.identifier("FlexibleNullability")) + + val ENHANCED_NULLABILITY_ANNOTATION_FQ_NAME: FqName = + JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION } } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt index 1f4271ee945..6443a223df5 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/AnnotationCodegen.kt @@ -186,7 +186,7 @@ abstract class AnnotationCodegen( if (retentionPolicy == RetentionPolicy.SOURCE) return null // FlexibleNullability is an internal annotation, used only inside the compiler - if (annotationClass.fqNameWhenAvailable == JvmGeneratorExtensions.FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME) return null + if (annotationClass.fqNameWhenAvailable in internalAnnotations) return null // We do not generate annotations whose classes are optional (annotated with `@OptionalExpectation`) because if an annotation entry // is resolved to the expected declaration, this means that annotation has no actual class, and thus should not be generated. @@ -296,9 +296,15 @@ abstract class AnnotationCodegen( KotlinRetention.RUNTIME to RetentionPolicy.RUNTIME ) + internal val internalAnnotations = setOf( + JvmGeneratorExtensions.FLEXIBLE_NULLABILITY_ANNOTATION_FQ_NAME, + JvmGeneratorExtensions.ENHANCED_NULLABILITY_ANNOTATION_FQ_NAME + ) + private fun getRetentionPolicy(irClass: IrClass): RetentionPolicy { val retention = irClass.getAnnotationRetention() if (retention != null) { + @Suppress("MapGetWithNotNullAssertionOperator") return annotationRetentionMap[retention]!! } irClass.getAnnotation(FqName(java.lang.annotation.Retention::class.java.name))?.let { retentionAnnotation -> @@ -374,7 +380,7 @@ private val RETENTION_PARAMETER_NAME = Name.identifier("value") private fun IrClass.getAnnotationRetention(): KotlinRetention? { val retentionArgument = getAnnotation(StandardNames.FqNames.retention)?.getValueArgument(RETENTION_PARAMETER_NAME) - as? IrGetEnumValue?: return null + as? IrGetEnumValue ?: return null val retentionArgumentValue = retentionArgument.symbol.owner return KotlinRetention.valueOf(retentionArgumentValue.name.asString()) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt index 1c074f8279d..47d77635cbf 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/StubGeneratorExtensions.kt @@ -35,6 +35,9 @@ open class StubGeneratorExtensions { open val flexibleNullabilityAnnotationConstructor: IrConstructor? get() = null + open val enhancedNullabilityAnnotationConstructor: IrConstructor? + get() = null + companion object { @JvmField val EMPTY = StubGeneratorExtensions() 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 31b6425e95c..8e39aa803ed 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 @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor -import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer @@ -87,9 +86,9 @@ class TypeTranslator( when { flexibleApproximatedType.isError -> - return IrErrorTypeImpl(flexibleApproximatedType, translateTypeAnnotations(flexibleApproximatedType.annotations), variance) + return IrErrorTypeImpl(flexibleApproximatedType, translateTypeAnnotations(flexibleApproximatedType), variance) flexibleApproximatedType.isDynamic() -> - return IrDynamicTypeImpl(flexibleApproximatedType, translateTypeAnnotations(flexibleApproximatedType.annotations), variance) + return IrDynamicTypeImpl(flexibleApproximatedType, translateTypeAnnotations(flexibleApproximatedType), variance) } val approximatedType = flexibleApproximatedType.upperIfFlexible() @@ -111,19 +110,19 @@ class TypeTranslator( return IrSimpleTypeBuilder().apply { this.kotlinType = flexibleApproximatedType - this.hasQuestionMark = approximatedType.isMarkedNullable || extensions.enhancedNullability.hasEnhancedNullability(approximatedType) + this.hasQuestionMark = approximatedType.isMarkedNullable this.variance = variance this.abbreviation = approximatedType.getAbbreviation()?.toIrTypeAbbreviation() when (ktTypeDescriptor) { is TypeParameterDescriptor -> { classifier = resolveTypeParameter(ktTypeDescriptor) - annotations = translateTypeAnnotations(approximatedType.annotations) + annotations = translateTypeAnnotations(approximatedType) } is ClassDescriptor -> { classifier = symbolTable.referenceClass(ktTypeDescriptor) arguments = translateTypeArguments(approximatedType.arguments) - annotations = translateTypeAnnotations(approximatedType.annotations) + annotations = translateTypeAnnotations(approximatedType) } else -> @@ -155,7 +154,7 @@ class TypeTranslator( symbolTable.referenceTypeAlias(typeAliasDescriptor), isMarkedNullable, translateTypeArguments(this.arguments), - translateTypeAnnotations(this.annotations) + translateTypeAnnotations(this) ) } @@ -195,8 +194,26 @@ class TypeTranslator( approximateCapturedTypes(ktType).upper } - private fun translateTypeAnnotations(annotations: Annotations): List = - annotations.mapNotNull(constantValueGenerator::generateAnnotationConstructorCall) + private fun translateTypeAnnotations(kotlinType: KotlinType): List { + val annotations = kotlinType.annotations + val irAnnotations = ArrayList() + annotations.mapNotNullTo(irAnnotations) { + constantValueGenerator.generateAnnotationConstructorCall(it) + } + // EnhancedNullability annotation is not present in 'annotations', see 'EnhancedTypeAnnotations::iterator()'. + if (extensions.enhancedNullability.hasEnhancedNullability(kotlinType)) { + extensions.enhancedNullabilityAnnotationConstructor?.let { irConstructor -> + irAnnotations.add( + IrConstructorCallImpl.fromSymbolOwner( + UNDEFINED_OFFSET, UNDEFINED_OFFSET, + irConstructor.constructedClassType, + irConstructor.symbol + ) + ) + } + } + return irAnnotations + } private fun translateTypeArguments(arguments: List) = arguments.map { diff --git a/compiler/testData/codegen/bytecodeListing/lateInitNotNull.kt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/lateInitNotNull.kt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/lateInitNotNull.kt rename to compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/lateInitNotNull.kt diff --git a/compiler/testData/codegen/bytecodeListing/lateInitNotNull.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/lateInitNotNull.txt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/lateInitNotNull.txt rename to compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/lateInitNotNull.txt diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.kt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.kt new file mode 100644 index 00000000000..8f45e3addd7 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.kt @@ -0,0 +1,17 @@ +// FILE: nullabilityAnnotationsForReturnType.kt + +fun testNotNull(): String = "" +fun testNullable(): String? = "" +fun testJavaNotNull() = J.returnsNotNull() +fun testJavaNullable() = J.returnsNullable() +fun testJavaFlexible() = J.returnsFlexible() + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static @NotNull String returnsNotNull() { return ""; } + public static @Nullable String returnsNullable() { return ""; } + public static String returnsFlexible() { return ""; } +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.txt new file mode 100644 index 00000000000..579763be054 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.txt @@ -0,0 +1,9 @@ +@kotlin.Metadata +public final class NullabilityAnnotationsForReturnTypeKt { + // source: 'nullabilityAnnotationsForReturnType.kt' + public final static method testJavaFlexible(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method testJavaNotNull(): java.lang.String + public final static @org.jetbrains.annotations.Nullable method testJavaNullable(): java.lang.String + public final static @org.jetbrains.annotations.NotNull method testNotNull(): java.lang.String + public final static @org.jetbrains.annotations.Nullable method testNullable(): java.lang.String +} diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.kt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.kt new file mode 100644 index 00000000000..d3a8dfa6cb3 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.kt @@ -0,0 +1,15 @@ +// FILE: nullabilityAnnotationsOnDelegatedMembers.kt +class JImpl(j: J) : J by j + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface J { + void takeNotNull(@NotNull String x); + void takeNullable(@Nullable String x); + void takeFlexible(String x); + @NotNull String returnNotNull(); + @Nullable String returnNullable(); + String returnsFlexible(); +} diff --git a/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.txt new file mode 100644 index 00000000000..6db44e8890f --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.txt @@ -0,0 +1,12 @@ +@kotlin.Metadata +public final class JImpl { + // source: 'nullabilityAnnotationsOnDelegatedMembers.kt' + private synthetic final field $$delegate_0: J + public method (@org.jetbrains.annotations.NotNull p0: J): void + public @org.jetbrains.annotations.NotNull method returnNotNull(): java.lang.String + public @org.jetbrains.annotations.Nullable method returnNullable(): java.lang.String + public method returnsFlexible(): java.lang.String + public method takeFlexible(p0: java.lang.String): void + public method takeNotNull(@org.jetbrains.annotations.NotNull p0: java.lang.String): void + public method takeNullable(@org.jetbrains.annotations.Nullable p0: java.lang.String): void +} diff --git a/compiler/testData/codegen/bytecodeListing/platformTypes.kt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/platformTypes.kt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/platformTypes.kt rename to compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/platformTypes.kt diff --git a/compiler/testData/codegen/bytecodeListing/platformTypes.txt b/compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/platformTypes.txt similarity index 100% rename from compiler/testData/codegen/bytecodeListing/platformTypes.txt rename to compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/platformTypes.txt diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt new file mode 100644 index 00000000000..a9dfe2f625e --- /dev/null +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.txt @@ -0,0 +1,63 @@ +FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt + CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test + CONSTRUCTOR visibility:public <> (j:.J) returnType:.Test [primary] + VALUE_PARAMETER name:j index:0 type:.J + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J]' + SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .Test declared in .Test' type=.Test origin=null + value: GET_VAR 'j: .J declared in .Test.' type=.J origin=null + PROPERTY name:j visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final] + EXPRESSION_BODY + GET_VAR 'j: .J declared in .Test.' type=.J origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.Test) returnType:.J + correspondingProperty: PROPERTY name:j visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): .J declared in .Test' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final] + FUN FAKE_OVERRIDE name:takeNotNull visibility:public modality:OPEN <> ($this:.J, x:kotlin.String) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun takeNotNull (x: kotlin.String): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.J + VALUE_PARAMETER name:x index:0 type:kotlin.String + FUN FAKE_OVERRIDE name:takeNullable visibility:public modality:OPEN <> ($this:.J, x:kotlin.String?) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun takeNullable (x: kotlin.String?): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.J + VALUE_PARAMETER name:x index:0 type:kotlin.String? + FUN FAKE_OVERRIDE name:takeFlexible visibility:public modality:OPEN <> ($this:.J, x:kotlin.String?) returnType:kotlin.Unit [fake_override] + overridden: + public abstract fun takeFlexible (x: kotlin.String?): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.J + VALUE_PARAMETER name:x index:0 type:kotlin.String? + FUN FAKE_OVERRIDE name:returnNotNull visibility:public modality:OPEN <> ($this:.J) returnType:kotlin.String [fake_override] + overridden: + public abstract fun returnNotNull (): kotlin.String declared in .J + $this: VALUE_PARAMETER name: type:.J + FUN FAKE_OVERRIDE name:returnNullable visibility:public modality:OPEN <> ($this:.J) returnType:kotlin.String? [fake_override] + overridden: + public abstract fun returnNullable (): kotlin.String? declared in .J + $this: VALUE_PARAMETER name: type:.J + FUN FAKE_OVERRIDE name:returnsFlexible visibility:public modality:OPEN <> ($this:.J) returnType:kotlin.String? [fake_override] + overridden: + public abstract fun returnsFlexible (): kotlin.String? declared in .J + $this: VALUE_PARAMETER name: type:.J + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt new file mode 100644 index 00000000000..2ac254b578f --- /dev/null +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt @@ -0,0 +1,17 @@ +// FILE: delegatedImplementationOfJavaInterface.kt + +class Test(private val j: J) : J by j + +// FILE: J.java + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface J { + void takeNotNull(@NotNull String x); + void takeNullable(@Nullable String x); + void takeFlexible(String x); + @NotNull String returnNotNull(); + @Nullable String returnNullable(); + String returnsFlexible(); +} diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.txt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.txt new file mode 100644 index 00000000000..db37084d385 --- /dev/null +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.txt @@ -0,0 +1,97 @@ +FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt + CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test + CONSTRUCTOR visibility:public <> (j:.J) returnType:.Test [primary] + VALUE_PARAMETER name:j index:0 type:.J + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.J]' + PROPERTY name:j visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final] + EXPRESSION_BODY + GET_VAR 'j: .J declared in .Test.' type=.J origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.Test) returnType:.J + correspondingProperty: PROPERTY name:j visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): .J declared in .Test' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.' type=.Test origin=null + FUN DELEGATED_MEMBER name:returnNotNull visibility:public modality:OPEN <> ($this:.Test) returnType:@[EnhancedNullability] kotlin.String + annotations: + NotNull(value = ) + overridden: + public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in .J + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in .Test' + CALL 'public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.returnNotNull' type=.Test origin=null + FUN DELEGATED_MEMBER name:returnNullable visibility:public modality:OPEN <> ($this:.Test) returnType:@[EnhancedNullability] kotlin.String? + annotations: + Nullable(value = ) + overridden: + public abstract fun returnNullable (): @[EnhancedNullability] kotlin.String? declared in .J + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun returnNullable (): @[EnhancedNullability] kotlin.String? declared in .Test' + CALL 'public abstract fun returnNullable (): @[EnhancedNullability] kotlin.String? declared in .J' type=@[EnhancedNullability] kotlin.String? origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.returnNullable' type=.Test origin=null + FUN DELEGATED_MEMBER name:returnsFlexible visibility:public modality:OPEN <> ($this:.Test) returnType:@[FlexibleNullability] kotlin.String? + overridden: + public abstract fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in .J + $this: VALUE_PARAMETER name: type:.Test + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in .Test' + CALL 'public abstract fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.returnsFlexible' type=.Test origin=null + FUN DELEGATED_MEMBER name:takeFlexible visibility:public modality:OPEN <> ($this:.Test, x:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Unit + overridden: + public abstract fun takeFlexible (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.Test + VALUE_PARAMETER name:x index:0 type:@[FlexibleNullability] kotlin.String? + BLOCK_BODY + CALL 'public abstract fun takeFlexible (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.takeFlexible' type=.Test origin=null + x: GET_VAR 'x: @[FlexibleNullability] kotlin.String? declared in .Test.takeFlexible' type=@[FlexibleNullability] kotlin.String? origin=null + FUN DELEGATED_MEMBER name:takeNotNull visibility:public modality:OPEN <> ($this:.Test, x:@[EnhancedNullability] kotlin.String) returnType:kotlin.Unit + overridden: + public abstract fun takeNotNull (x: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.Test + VALUE_PARAMETER name:x index:0 type:@[EnhancedNullability] kotlin.String + annotations: + NotNull(value = ) + BLOCK_BODY + CALL 'public abstract fun takeNotNull (x: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.takeNotNull' type=.Test origin=null + x: GET_VAR 'x: @[EnhancedNullability] kotlin.String declared in .Test.takeNotNull' type=@[EnhancedNullability] kotlin.String origin=null + FUN DELEGATED_MEMBER name:takeNullable visibility:public modality:OPEN <> ($this:.Test, x:@[EnhancedNullability] kotlin.String?) returnType:kotlin.Unit + overridden: + public abstract fun takeNullable (x: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.Test + VALUE_PARAMETER name:x index:0 type:@[EnhancedNullability] kotlin.String? + annotations: + Nullable(value = ) + BLOCK_BODY + CALL 'public abstract fun takeNullable (x: @[EnhancedNullability] kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null + receiver: GET_VAR ': .Test declared in .Test.takeNullable' type=.Test origin=null + x: GET_VAR 'x: @[EnhancedNullability] kotlin.String? declared in .Test.takeNullable' type=@[EnhancedNullability] kotlin.String? origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .J + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .J + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .J + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt index 9d64b8e39f5..5eba131fe43 100644 --- a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt @@ -27,9 +27,9 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .JFoo $this: VALUE_PARAMETER name: type:kotlin.Any VALUE_PARAMETER name:other index:0 type:kotlin.Any? - FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:.JFoo) returnType:kotlin.String? [fake_override] + FUN FAKE_OVERRIDE name:foo visibility:public modality:OPEN <> ($this:.JFoo) returnType:@[EnhancedNullability] kotlin.String [fake_override] overridden: - public open fun foo (): kotlin.String? declared in .JFoo + public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo $this: VALUE_PARAMETER name: type:.JFoo FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] overridden: @@ -47,12 +47,12 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K2 modality:FINAL visibility:public superTypes:[.JFoo]' FUN name:foo visibility:public modality:OPEN <> ($this:.K2) returnType:kotlin.String overridden: - public open fun foo (): kotlin.String? declared in .JFoo + public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo $this: VALUE_PARAMETER name: type:.K2 BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .K2' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): kotlin.String? declared in .JFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JFoo modality:OPEN visibility:public superTypes:[.IFoo]' type=kotlin.String? origin=null + CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:JFoo modality:OPEN visibility:public superTypes:[.IFoo]' type=@[EnhancedNullability] kotlin.String origin=null $this: GET_VAR ': .K2 declared in .K2.foo' type=.K2 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -141,7 +141,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestJFoo' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): kotlin.String? declared in .JFoo' type=kotlin.String? origin=null + CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String declared in .JFoo' type=@[EnhancedNullability] kotlin.String origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.JFoo visibility:private [final]' type=.JFoo origin=null receiver: GET_VAR ': .TestJFoo declared in .TestJFoo.foo' type=.TestJFoo origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] @@ -173,7 +173,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK1' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun foo (): kotlin.String? [fake_override] declared in .K1' type=kotlin.String? origin=null + CALL 'public open fun foo (): @[EnhancedNullability] kotlin.String [fake_override] declared in .K1' type=@[EnhancedNullability] kotlin.String origin=null $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K1 visibility:private [final]' type=.K1 origin=null receiver: GET_VAR ': .TestK1 declared in .TestK1.foo' type=.TestK1 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/expressions/nullCheckOnGenericLambdaReturn.txt b/compiler/testData/ir/irText/expressions/nullCheckOnGenericLambdaReturn.txt index 993d536968a..124ddabc702 100644 --- a/compiler/testData/ir/irText/expressions/nullCheckOnGenericLambdaReturn.txt +++ b/compiler/testData/ir/irText/expressions/nullCheckOnGenericLambdaReturn.txt @@ -45,13 +45,13 @@ FILE fqName: fileName:/nullCheckOnGenericLambdaReturn.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.String declared in ' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public final fun checkT (fn: kotlin.Function0.checkT>): T of .checkT declared in ' type=kotlin.String? origin=null - : kotlin.String? - fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + CALL 'public final fun checkT (fn: kotlin.Function0.checkT>): T of .checkT declared in ' type=@[EnhancedNullability] kotlin.String origin=null + : @[EnhancedNullability] kotlin.String + fn: FUN_EXPR type=kotlin.Function0<@[EnhancedNullability] kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[EnhancedNullability] kotlin.String BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .test2' - CALL 'public open fun nnFoo (): kotlin.String? declared in .J' type=kotlin.String? origin=null + RETURN type=kotlin.Nothing from='local final fun (): @[EnhancedNullability] kotlin.String declared in .test2' + CALL 'public open fun nnFoo (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null FUN name:test3 visibility:public modality:FINAL <> () returnType:@[FlexibleNullability] kotlin.String? BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (): @[FlexibleNullability] kotlin.String? declared in ' @@ -66,10 +66,10 @@ FILE fqName: fileName:/nullCheckOnGenericLambdaReturn.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (): kotlin.String declared in ' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public final fun checkTAny (fn: kotlin.Function0.checkTAny>): T of .checkTAny declared in ' type=kotlin.String? origin=null - : kotlin.String? - fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + CALL 'public final fun checkTAny (fn: kotlin.Function0.checkTAny>): T of .checkTAny declared in ' type=@[EnhancedNullability] kotlin.String origin=null + : @[EnhancedNullability] kotlin.String + fn: FUN_EXPR type=kotlin.Function0<@[EnhancedNullability] kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[EnhancedNullability] kotlin.String BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .test4' - CALL 'public open fun nnFoo (): kotlin.String? declared in .J' type=kotlin.String? origin=null + RETURN type=kotlin.Nothing from='local final fun (): @[EnhancedNullability] kotlin.String declared in .test4' + CALL 'public open fun nnFoo (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.txt b/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.txt index f42a497d590..5aa1e7ee216 100644 --- a/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.txt +++ b/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.txt @@ -87,4 +87,4 @@ FILE fqName: fileName:/nullCheckOnLambdaReturn.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Any? BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (): kotlin.Any? declared in .test6' - CALL 'public open fun nnFoo (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun nnFoo (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/firProblems/putIfAbsent.txt b/compiler/testData/ir/irText/firProblems/putIfAbsent.txt index f87593fec94..bec7c5565e4 100644 --- a/compiler/testData/ir/irText/firProblems/putIfAbsent.txt +++ b/compiler/testData/ir/irText/firProblems/putIfAbsent.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/putIfAbsent.kt : T of .Owner.foo : T of .Owner.foo TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public open fun putIfAbsent (p0: K of kotlin.collections.MutableMap?, p1: V of kotlin.collections.MutableMap?): V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=T of .Owner.foo? origin=null + CALL 'public open fun putIfAbsent (p0: @[EnhancedNullability] K of kotlin.collections.MutableMap, p1: @[EnhancedNullability] V of kotlin.collections.MutableMap): @[EnhancedNullability] V of kotlin.collections.MutableMap? declared in kotlin.collections.MutableMap' type=@[EnhancedNullability] T of .Owner.foo? origin=null $this: GET_VAR 'val map: kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> [val] declared in .Owner.foo' type=kotlin.collections.MutableMap.Owner.foo, T of .Owner.foo> origin=null p0: GET_VAR 'x: T of .Owner.foo declared in .Owner.foo' type=T of .Owner.foo origin=null p1: GET_VAR 'y: T of .Owner.foo declared in .Owner.foo' type=T of .Owner.foo origin=null diff --git a/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt b/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt index a208a64723b..cbe81bfb666 100644 --- a/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt +++ b/compiler/testData/ir/irText/regressions/typeParametersInImplicitCast.txt @@ -8,12 +8,12 @@ FILE fqName: fileName:/typeParametersInImplicitCast.kt : kotlin.collections.List.problematic> : T of .problematic? $receiver: GET_VAR 'lss: kotlin.collections.List.problematic>> declared in .problematic' type=kotlin.collections.List.problematic>> origin=null - transform: FUN_EXPR type=kotlin.Function1.problematic>, kotlin.collections.List.problematic?>?> origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.collections.List.problematic>) returnType:kotlin.collections.List.problematic?>? + transform: FUN_EXPR type=kotlin.Function1.problematic>, @[EnhancedNullability] kotlin.collections.List.problematic?>> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.collections.List.problematic>) returnType:@[EnhancedNullability] kotlin.collections.List.problematic?> VALUE_PARAMETER name:it index:0 type:kotlin.collections.List.problematic> BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (it: kotlin.collections.List.problematic>): kotlin.collections.List.problematic?>? declared in .problematic' + RETURN type=kotlin.Nothing from='local final fun (it: kotlin.collections.List.problematic>): @[EnhancedNullability] kotlin.collections.List.problematic?> declared in .problematic' TYPE_OP type=kotlin.collections.List.problematic?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List.problematic?> - CALL 'public/*package*/ open fun id (v: @[FlexibleNullability] kotlin.collections.List.ListId.id?>?): kotlin.collections.List.ListId.id?>? declared in .ListId' type=kotlin.collections.List.problematic?>? origin=null + CALL 'public/*package*/ open fun id (v: @[FlexibleNullability] kotlin.collections.List.ListId.id?>?): @[EnhancedNullability] kotlin.collections.List.ListId.id?> declared in .ListId' type=@[EnhancedNullability] kotlin.collections.List.problematic?> origin=null : T of .problematic? v: GET_VAR 'it: kotlin.collections.List.problematic> declared in .problematic.' type=kotlin.collections.List.problematic> origin=null diff --git a/compiler/testData/ir/irText/stubs/builtinMap.txt b/compiler/testData/ir/irText/stubs/builtinMap.txt index c9b73033d24..96d77ecdabc 100644 --- a/compiler/testData/ir/irText/stubs/builtinMap.txt +++ b/compiler/testData/ir/irText/stubs/builtinMap.txt @@ -27,7 +27,7 @@ FILE fqName: fileName:/builtinMap.kt $receiver: VALUE_PARAMETER name: type:java.util.LinkedHashMap.plus?, V1 of .plus?>{ kotlin.collections.LinkedHashMap.plus?, V1 of .plus?> } BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public open fun put (key: K of java.util.LinkedHashMap?, value: V of java.util.LinkedHashMap?): V of java.util.LinkedHashMap? [fake_override] declared in java.util.LinkedHashMap' type=V1 of .plus? origin=null + CALL 'public open fun put (key: @[EnhancedNullability] K of java.util.LinkedHashMap, value: @[EnhancedNullability] V of java.util.LinkedHashMap): @[EnhancedNullability] V of java.util.LinkedHashMap? [fake_override] declared in java.util.LinkedHashMap' type=@[EnhancedNullability] V1 of .plus? origin=null $this: GET_VAR ': java.util.LinkedHashMap.plus?, V1 of .plus?>{ kotlin.collections.LinkedHashMap.plus?, V1 of .plus?> } declared in .plus.' type=java.util.LinkedHashMap.plus?, V1 of .plus?>{ kotlin.collections.LinkedHashMap.plus?, V1 of .plus?> } origin=null key: CALL 'public final fun (): A of kotlin.Pair declared in kotlin.Pair' type=K1 of .plus origin=GET_PROPERTY $this: GET_VAR 'pair: kotlin.Pair.plus, V1 of .plus> declared in .plus' type=kotlin.Pair.plus, V1 of .plus> origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.txt index 2b8d09b1db3..43519382280 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullability.txt @@ -6,22 +6,22 @@ FILE fqName: fileName:/enhancedNullability.kt BLOCK_BODY CALL 'public final fun use (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null FUN name:testLocalVal visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:local type:kotlin.String [val] TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null FUN name:testReturnValue visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testReturnValue (): kotlin.String declared in ' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null PROPERTY name:testGlobalVal visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:testGlobalVal type:kotlin.String visibility:private [final,static] EXPRESSION_BODY TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:testGlobalVal visibility:public modality:FINAL [val] BLOCK_BODY @@ -33,21 +33,21 @@ FILE fqName: fileName:/enhancedNullability.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in ' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null FUN name:testJUse visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public open fun use (s: kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + CALL 'public open fun use (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J' type=kotlin.Unit origin=null s: CALL 'public open fun nullString (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null - CALL 'public open fun use (s: kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - s: CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public open fun use (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + s: CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null FUN name:testLocalVarUse visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:ns type:@[FlexibleNullability] kotlin.String? [val] CALL 'public open fun nullString (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null - CALL 'public open fun use (s: kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + CALL 'public open fun use (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J' type=kotlin.Unit origin=null s: GET_VAR 'val ns: @[FlexibleNullability] kotlin.String? [val] declared in .testLocalVarUse' type=@[FlexibleNullability] kotlin.String? origin=null VAR name:nns type:kotlin.String [val] TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL 'public open fun notNullString (): kotlin.String? declared in .J' type=kotlin.String? origin=null - CALL 'public open fun use (s: kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null + CALL 'public open fun use (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J' type=kotlin.Unit origin=null s: GET_VAR 'val nns: kotlin.String [val] declared in .testLocalVarUse' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt index 4b159efac85..94a7b9ef363 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.txt @@ -118,89 +118,89 @@ FILE fqName: fileName:/enhancedNullabilityInDestructuringAssignment.kt FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION - VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.P? [val] - CALL 'public open fun notNullP (): .P? declared in .J' type=.P? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:@[EnhancedNullability] .P [val] + CALL 'public open fun notNullP (): @[EnhancedNullability] .P declared in .J' type=@[EnhancedNullability] .P origin=null VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in .P' type=kotlin.Int origin=COMPONENT_N(index=1) $this: TYPE_OP type=.P origin=IMPLICIT_NOTNULL typeOperand=.P - GET_VAR 'val tmp_0: .P? [val] declared in .test1' type=.P? origin=null + GET_VAR 'val tmp_0: @[EnhancedNullability] .P [val] declared in .test1' type=@[EnhancedNullability] .P origin=null VAR name:y type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int [operator] declared in .P' type=kotlin.Int origin=COMPONENT_N(index=2) $this: TYPE_OP type=.P origin=IMPLICIT_NOTNULL typeOperand=.P - GET_VAR 'val tmp_0: .P? [val] declared in .test1' type=.P? origin=null + GET_VAR 'val tmp_0: @[EnhancedNullability] .P [val] declared in .test1' type=@[EnhancedNullability] .P origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null y: GET_VAR 'val y: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] - CALL 'public open fun notNullComponents (): @[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? declared in .J' type=@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null - VAR name:x type:@[NotNull(value = )] kotlin.String? [val] - CALL 'public final fun component1 (): T1 of .Q [operator] declared in .Q' type=@[NotNull(value = )] kotlin.String? origin=COMPONENT_N(index=1) - $this: TYPE_OP type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> - GET_VAR 'val tmp_1: @[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] declared in .test2' type=@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null - VAR name:y type:@[NotNull(value = )] kotlin.String? [val] - CALL 'public final fun component2 (): T2 of .Q [operator] declared in .Q' type=@[NotNull(value = )] kotlin.String? origin=COMPONENT_N(index=2) - $this: TYPE_OP type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> - GET_VAR 'val tmp_1: @[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] declared in .test2' type=@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? [val] + CALL 'public open fun notNullComponents (): @[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? declared in .J' type=@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? origin=null + VAR name:x type:@[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] + CALL 'public final fun component1 (): T1 of .Q [operator] declared in .Q' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=COMPONENT_N(index=1) + $this: TYPE_OP type=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> + GET_VAR 'val tmp_1: @[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? [val] declared in .test2' type=@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? origin=null + VAR name:y type:@[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] + CALL 'public final fun component2 (): T2 of .Q [operator] declared in .Q' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=COMPONENT_N(index=2) + $this: TYPE_OP type=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> + GET_VAR 'val tmp_1: @[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? [val] declared in .test2' type=@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: TYPE_OP type=@[NotNull(value = )] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] kotlin.String - GET_VAR 'val x: @[NotNull(value = )] kotlin.String? [val] declared in .test2' type=@[NotNull(value = )] kotlin.String? origin=null + GET_VAR 'val x: @[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] declared in .test2' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=null y: TYPE_OP type=@[NotNull(value = )] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] kotlin.String - GET_VAR 'val y: @[NotNull(value = )] kotlin.String? [val] declared in .test2' type=@[NotNull(value = )] kotlin.String? origin=null + GET_VAR 'val y: @[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] declared in .test2' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=null FUN name:test2Desugared visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:tmp type:@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] - CALL 'public open fun notNullComponents (): @[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? declared in .J' type=@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null + VAR name:tmp type:@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? [val] + CALL 'public open fun notNullComponents (): @[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? declared in .J' type=@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? origin=null VAR name:x type:@[NotNull(value = )] kotlin.String [val] TYPE_OP type=@[NotNull(value = )] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] kotlin.String - CALL 'public final fun component1 (): T1 of .Q [operator] declared in .Q' type=@[NotNull(value = )] kotlin.String? origin=null - $this: TYPE_OP type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> - GET_VAR 'val tmp: @[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] declared in .test2Desugared' type=@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null + CALL 'public final fun component1 (): T1 of .Q [operator] declared in .Q' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=null + $this: TYPE_OP type=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> + GET_VAR 'val tmp: @[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? [val] declared in .test2Desugared' type=@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? origin=null VAR name:y type:@[NotNull(value = )] kotlin.String [val] TYPE_OP type=@[NotNull(value = )] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] kotlin.String - CALL 'public final fun component2 (): T2 of .Q [operator] declared in .Q' type=@[NotNull(value = )] kotlin.String? origin=null - $this: TYPE_OP type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> - GET_VAR 'val tmp: @[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] declared in .test2Desugared' type=@[FlexibleNullability] .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null + CALL 'public final fun component2 (): T2 of .Q [operator] declared in .Q' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=null + $this: TYPE_OP type=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> + GET_VAR 'val tmp: @[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? [val] declared in .test2Desugared' type=@[FlexibleNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String>? origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: @[NotNull(value = )] kotlin.String [val] declared in .test2Desugared' type=@[NotNull(value = )] kotlin.String origin=null y: GET_VAR 'val y: @[NotNull(value = )] kotlin.String [val] declared in .test2Desugared' type=@[NotNull(value = )] kotlin.String origin=null FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] - CALL 'public open fun notNullQAndComponents (): .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? declared in .J' type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null - VAR name:x type:@[NotNull(value = )] kotlin.String? [val] - CALL 'public final fun component1 (): T1 of .Q [operator] declared in .Q' type=@[NotNull(value = )] kotlin.String? origin=COMPONENT_N(index=1) - $this: TYPE_OP type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> - GET_VAR 'val tmp_2: .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] declared in .test3' type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null - VAR name:y type:@[NotNull(value = )] kotlin.String? [val] - CALL 'public final fun component2 (): T2 of .Q [operator] declared in .Q' type=@[NotNull(value = )] kotlin.String? origin=COMPONENT_N(index=2) - $this: TYPE_OP type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?> - GET_VAR 'val tmp_2: .Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? [val] declared in .test3' type=.Q<@[NotNull(value = )] kotlin.String?, @[NotNull(value = )] kotlin.String?>? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:@[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> [val] + CALL 'public open fun notNullQAndComponents (): @[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> declared in .J' type=@[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=null + VAR name:x type:@[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] + CALL 'public final fun component1 (): T1 of .Q [operator] declared in .Q' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=COMPONENT_N(index=1) + $this: TYPE_OP type=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> + GET_VAR 'val tmp_2: @[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> [val] declared in .test3' type=@[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=null + VAR name:y type:@[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] + CALL 'public final fun component2 (): T2 of .Q [operator] declared in .Q' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=COMPONENT_N(index=2) + $this: TYPE_OP type=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=IMPLICIT_NOTNULL typeOperand=.Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> + GET_VAR 'val tmp_2: @[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> [val] declared in .test3' type=@[EnhancedNullability] .Q<@[NotNull(value = )] @[EnhancedNullability] kotlin.String, @[NotNull(value = )] @[EnhancedNullability] kotlin.String> origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: TYPE_OP type=@[NotNull(value = )] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] kotlin.String - GET_VAR 'val x: @[NotNull(value = )] kotlin.String? [val] declared in .test3' type=@[NotNull(value = )] kotlin.String? origin=null + GET_VAR 'val x: @[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] declared in .test3' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=null y: TYPE_OP type=@[NotNull(value = )] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] kotlin.String - GET_VAR 'val y: @[NotNull(value = )] kotlin.String? [val] declared in .test3' type=@[NotNull(value = )] kotlin.String? origin=null + GET_VAR 'val y: @[NotNull(value = )] @[EnhancedNullability] kotlin.String [val] declared in .test3' type=@[NotNull(value = )] @[EnhancedNullability] kotlin.String origin=null FUN name:test4 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> [val] - CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> origin=null - : kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> - $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections' type=kotlin.collections.Iterable)] .P?>> origin=null - : @[NotNull(value = )] .P? - $receiver: TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] .P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] .P?> - CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> [val] + CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null + : kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> + $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections' type=kotlin.collections.Iterable)] @[EnhancedNullability] .P>> origin=null + : @[NotNull(value = )] @[EnhancedNullability] .P + $receiver: TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> + CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? origin=null VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in kotlin.collections.IndexedValue' type=kotlin.Int origin=COMPONENT_N(index=1) - $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> [val] declared in .test4' type=kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> origin=null - VAR name:y type:@[NotNull(value = )] .P? [val] - CALL 'public final fun component2 (): T of kotlin.collections.IndexedValue [operator] declared in kotlin.collections.IndexedValue' type=@[NotNull(value = )] .P? origin=COMPONENT_N(index=2) - $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> [val] declared in .test4' type=kotlin.collections.IndexedValue<@[NotNull(value = )] .P?> origin=null + $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .test4' type=kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null + VAR name:y type:@[NotNull(value = )] @[EnhancedNullability] .P [val] + CALL 'public final fun component2 (): T of kotlin.collections.IndexedValue [operator] declared in kotlin.collections.IndexedValue' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=COMPONENT_N(index=2) + $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .test4' type=kotlin.collections.IndexedValue<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: kotlin.Int [val] declared in .test4' type=kotlin.Int origin=null y: TYPE_OP type=@[NotNull(value = )] .P origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] .P - GET_VAR 'val y: @[NotNull(value = )] .P? [val] declared in .test4' type=@[NotNull(value = )] .P? origin=null + GET_VAR 'val y: @[NotNull(value = )] @[EnhancedNullability] .P [val] declared in .test4' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.txt index 1d660a2c97d..59756746401 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.txt @@ -5,120 +5,120 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt FUN name:testForInListUnused visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=FOR_LOOP_ITERATOR + VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=FOR_LOOP_ITERATOR $this: TYPE_OP type=kotlin.collections.MutableList<*> origin=IMPLICIT_CAST typeOperand=kotlin.collections.MutableList<*> - TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] .P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] .P?> - CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? origin=null + TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> + CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name:x type:@[NotNull(value = )] .P? [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] .P? origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + VAR FOR_LOOP_VARIABLE name:x type:@[NotNull(value = )] @[EnhancedNullability] .P [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null BLOCK type=kotlin.Unit origin=null FUN name:testForInListDestructured visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=FOR_LOOP_ITERATOR + VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=FOR_LOOP_ITERATOR $this: TYPE_OP type=kotlin.collections.MutableList<*> origin=IMPLICIT_CAST typeOperand=kotlin.collections.MutableList<*> - TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] .P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] .P?> - CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? origin=null + TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> + CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:@[NotNull(value = )] .P? [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] .P? origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:@[NotNull(value = )] @[EnhancedNullability] .P [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in .P' type=kotlin.Int origin=COMPONENT_N(index=1) $this: TYPE_OP type=@[NotNull(value = )] .P origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] .P - GET_VAR 'val tmp_2: @[NotNull(value = )] .P? [val] declared in .testForInListDestructured' type=@[NotNull(value = )] .P? origin=null + GET_VAR 'val tmp_2: @[NotNull(value = )] @[EnhancedNullability] .P [val] declared in .testForInListDestructured' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=null VAR name:y type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int [operator] declared in .P' type=kotlin.Int origin=COMPONENT_N(index=2) $this: TYPE_OP type=@[NotNull(value = )] .P origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] .P - GET_VAR 'val tmp_2: @[NotNull(value = )] .P? [val] declared in .testForInListDestructured' type=@[NotNull(value = )] .P? origin=null + GET_VAR 'val tmp_2: @[NotNull(value = )] @[EnhancedNullability] .P [val] declared in .testForInListDestructured' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=null BLOCK type=kotlin.Unit origin=null FUN name:testDesugaredForInList visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:iterator type:kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + VAR name:iterator type:kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null $this: TYPE_OP type=kotlin.collections.MutableList<*> origin=IMPLICIT_CAST typeOperand=kotlin.collections.MutableList<*> - TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] .P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] .P?> - CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? origin=null + TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> + CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? origin=null WHILE label=null origin=WHILE_LOOP condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableIterator' type=kotlin.Boolean origin=null - $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null body: BLOCK type=kotlin.Unit origin=null VAR name:x type:@[NotNull(value = )] .P [val] TYPE_OP type=@[NotNull(value = )] .P origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] .P - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] .P? origin=null - $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=null + $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null FUN name:testForInArrayUnused visibility:public modality:FINAL <> (j:.J) returnType:kotlin.Unit VALUE_PARAMETER name:j index:0 type:.J BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.Iterator<.P?> [val] - CALL 'public final fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.Array' type=kotlin.collections.Iterator<.P?> origin=FOR_LOOP_ITERATOR - $this: TYPE_OP type=kotlin.Array<.P?> origin=IMPLICIT_CAST typeOperand=kotlin.Array<.P?> - TYPE_OP type=kotlin.Array.P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array.P?> - CALL 'public open fun arrayOfNotNull (): kotlin.Array.P?>? declared in .J' type=kotlin.Array.P?>? origin=null + VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.Iterator<@[EnhancedNullability] .P> [val] + CALL 'public final fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.Array' type=kotlin.collections.Iterator<@[EnhancedNullability] .P> origin=FOR_LOOP_ITERATOR + $this: TYPE_OP type=kotlin.Array<@[EnhancedNullability] .P> origin=IMPLICIT_CAST typeOperand=kotlin.Array<@[EnhancedNullability] .P> + TYPE_OP type=kotlin.Array.P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array.P> + CALL 'public open fun arrayOfNotNull (): @[EnhancedNullability] kotlin.Array.P> declared in .J' type=@[EnhancedNullability] kotlin.Array.P> origin=null $this: GET_VAR 'j: .J declared in .testForInArrayUnused' type=.J origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUnused' type=kotlin.collections.Iterator<.P?> origin=null + $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<@[EnhancedNullability] .P> [val] declared in .testForInArrayUnused' type=kotlin.collections.Iterator<@[EnhancedNullability] .P> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name:x type:.P? [val] - CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUnused' type=kotlin.collections.Iterator<.P?> origin=null + VAR FOR_LOOP_VARIABLE name:x type:@[EnhancedNullability] .P [val] + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=@[EnhancedNullability] .P origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_3: kotlin.collections.Iterator<@[EnhancedNullability] .P> [val] declared in .testForInArrayUnused' type=kotlin.collections.Iterator<@[EnhancedNullability] .P> origin=null BLOCK type=kotlin.Unit origin=null FUN name:testForInListUse visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_4 type:kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=FOR_LOOP_ITERATOR + VAR FOR_LOOP_ITERATOR name:tmp_4 type:kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableList' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=FOR_LOOP_ITERATOR $this: TYPE_OP type=kotlin.collections.MutableList<*> origin=IMPLICIT_CAST typeOperand=kotlin.collections.MutableList<*> - TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] .P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] .P?> - CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] .P?>? origin=null + TYPE_OP type=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P> + CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[NotNull(value = )] @[EnhancedNullability] .P>? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.MutableIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_4: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + $this: GET_VAR 'val tmp_4: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name:x type:@[NotNull(value = )] .P? [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] .P? origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_4: kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<@[NotNull(value = )] .P?> origin=null + VAR FOR_LOOP_VARIABLE name:x type:@[NotNull(value = )] @[EnhancedNullability] .P [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [fake_override,operator] declared in kotlin.collections.MutableIterator' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_4: kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<@[NotNull(value = )] @[EnhancedNullability] .P> origin=null BLOCK type=kotlin.Unit origin=null CALL 'public final fun use (s: .P): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=@[NotNull(value = )] .P origin=IMPLICIT_NOTNULL typeOperand=@[NotNull(value = )] .P - GET_VAR 'val x: @[NotNull(value = )] .P? [val] declared in .testForInListUse' type=@[NotNull(value = )] .P? origin=null - CALL 'public open fun use (s: .P?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - s: GET_VAR 'val x: @[NotNull(value = )] .P? [val] declared in .testForInListUse' type=@[NotNull(value = )] .P? origin=null + GET_VAR 'val x: @[NotNull(value = )] @[EnhancedNullability] .P [val] declared in .testForInListUse' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=null + CALL 'public open fun use (s: @[EnhancedNullability] .P): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + s: GET_VAR 'val x: @[NotNull(value = )] @[EnhancedNullability] .P [val] declared in .testForInListUse' type=@[NotNull(value = )] @[EnhancedNullability] .P origin=null FUN name:testForInArrayUse visibility:public modality:FINAL <> (j:.J) returnType:kotlin.Unit VALUE_PARAMETER name:j index:0 type:.J BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.Iterator<.P?> [val] - CALL 'public final fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.Array' type=kotlin.collections.Iterator<.P?> origin=FOR_LOOP_ITERATOR - $this: TYPE_OP type=kotlin.Array<.P?> origin=IMPLICIT_CAST typeOperand=kotlin.Array<.P?> - TYPE_OP type=kotlin.Array.P?> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array.P?> - CALL 'public open fun arrayOfNotNull (): kotlin.Array.P?>? declared in .J' type=kotlin.Array.P?>? origin=null + VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.Iterator<@[EnhancedNullability] .P> [val] + CALL 'public final fun iterator (): kotlin.collections.Iterator [operator] declared in kotlin.Array' type=kotlin.collections.Iterator<@[EnhancedNullability] .P> origin=FOR_LOOP_ITERATOR + $this: TYPE_OP type=kotlin.Array<@[EnhancedNullability] .P> origin=IMPLICIT_CAST typeOperand=kotlin.Array<@[EnhancedNullability] .P> + TYPE_OP type=kotlin.Array.P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Array.P> + CALL 'public open fun arrayOfNotNull (): @[EnhancedNullability] kotlin.Array.P> declared in .J' type=@[EnhancedNullability] kotlin.Array.P> origin=null $this: GET_VAR 'j: .J declared in .testForInArrayUse' type=.J origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUse' type=kotlin.collections.Iterator<.P?> origin=null + $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<@[EnhancedNullability] .P> [val] declared in .testForInArrayUse' type=kotlin.collections.Iterator<@[EnhancedNullability] .P> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name:x type:.P? [val] - CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<.P?> [val] declared in .testForInArrayUse' type=kotlin.collections.Iterator<.P?> origin=null + VAR FOR_LOOP_VARIABLE name:x type:@[EnhancedNullability] .P [val] + CALL 'public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator' type=@[EnhancedNullability] .P origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_5: kotlin.collections.Iterator<@[EnhancedNullability] .P> [val] declared in .testForInArrayUse' type=kotlin.collections.Iterator<@[EnhancedNullability] .P> origin=null BLOCK type=kotlin.Unit origin=null CALL 'public final fun use (s: .P): kotlin.Unit declared in ' type=kotlin.Unit origin=null s: TYPE_OP type=.P origin=IMPLICIT_NOTNULL typeOperand=.P - GET_VAR 'val x: .P? [val] declared in .testForInArrayUse' type=.P? origin=null - CALL 'public open fun use (s: .P?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - s: GET_VAR 'val x: .P? [val] declared in .testForInArrayUse' type=.P? origin=null + GET_VAR 'val x: @[EnhancedNullability] .P [val] declared in .testForInArrayUse' type=@[EnhancedNullability] .P origin=null + CALL 'public open fun use (s: @[EnhancedNullability] .P): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + s: GET_VAR 'val x: @[EnhancedNullability] .P [val] declared in .testForInArrayUse' type=@[EnhancedNullability] .P origin=null CLASS INTERFACE name:K modality:ABSTRACT visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K FUN name:arrayOfNotNull visibility:public modality:ABSTRACT <> ($this:.K) returnType:kotlin.Array<.P> diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index e6036cf8e63..15bcce7f744 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -94,11 +94,6 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/jvmStaticWithDefaultParameters.kt"); } - @TestMetadata("lateInitNotNull.kt") - public void testLateInitNotNull() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/lateInitNotNull.kt"); - } - @TestMetadata("localFunctionInInitBlock.kt") public void testLocalFunctionInInitBlock() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/localFunctionInInitBlock.kt"); @@ -139,11 +134,6 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/noToArrayInJava.kt"); } - @TestMetadata("platformTypes.kt") - public void testPlatformTypes() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/platformTypes.kt"); - } - @TestMetadata("privateDefaultImpls.kt") public void testPrivateDefaultImpls() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/privateDefaultImpls.kt"); @@ -669,6 +659,39 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { } } + @TestMetadata("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullabilityAnnotations extends AbstractBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNullabilityAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("lateInitNotNull.kt") + public void testLateInitNotNull() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/lateInitNotNull.kt"); + } + + @TestMetadata("nullabilityAnnotationsForReturnType.kt") + public void testNullabilityAnnotationsForReturnType() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.kt"); + } + + @TestMetadata("nullabilityAnnotationsOnDelegatedMembers.kt") + public void testNullabilityAnnotationsOnDelegatedMembers() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.kt"); + } + + @TestMetadata("platformTypes.kt") + public void testPlatformTypes() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/platformTypes.kt"); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index ec1dff307d2..54728756c34 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -94,11 +94,6 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/jvmStaticWithDefaultParameters.kt"); } - @TestMetadata("lateInitNotNull.kt") - public void testLateInitNotNull() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/lateInitNotNull.kt"); - } - @TestMetadata("localFunctionInInitBlock.kt") public void testLocalFunctionInInitBlock() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/localFunctionInInitBlock.kt"); @@ -139,11 +134,6 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/noToArrayInJava.kt"); } - @TestMetadata("platformTypes.kt") - public void testPlatformTypes() throws Exception { - runTest("compiler/testData/codegen/bytecodeListing/platformTypes.kt"); - } - @TestMetadata("privateDefaultImpls.kt") public void testPrivateDefaultImpls() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/privateDefaultImpls.kt"); @@ -639,6 +629,39 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes } } + @TestMetadata("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullabilityAnnotations extends AbstractIrBytecodeListingTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInNullabilityAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("lateInitNotNull.kt") + public void testLateInitNotNull() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/lateInitNotNull.kt"); + } + + @TestMetadata("nullabilityAnnotationsForReturnType.kt") + public void testNullabilityAnnotationsForReturnType() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsForReturnType.kt"); + } + + @TestMetadata("nullabilityAnnotationsOnDelegatedMembers.kt") + public void testNullabilityAnnotationsOnDelegatedMembers() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/nullabilityAnnotationsOnDelegatedMembers.kt"); + } + + @TestMetadata("platformTypes.kt") + public void testPlatformTypes() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/nullabilityAnnotations/platformTypes.kt"); + } + } + @TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 45326ae0400..15068dfb356 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -95,6 +95,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/classes/delegatedImplementation.kt"); } + @TestMetadata("delegatedImplementationOfJavaInterface.kt") + public void testDelegatedImplementationOfJavaInterface() throws Exception { + runTest("compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.kt"); + } + @TestMetadata("delegatedImplementationWithExplicitOverride.kt") public void testDelegatedImplementationWithExplicitOverride() throws Exception { runTest("compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.kt"); diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index c4d3f0e7243..76613d1744b 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -54,6 +54,8 @@ public final class JvmAnnotationNames { public static final FqName PURELY_IMPLEMENTS_ANNOTATION = new FqName("kotlin.jvm.PurelyImplements"); + public static final FqName KOTLIN_JVM_INTERNAL = new FqName("kotlin.jvm.internal"); + // Just for internal use: there is no such real classes in bytecode public static final FqName ENHANCED_NULLABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedNullability"); public static final FqName ENHANCED_MUTABILITY_ANNOTATION = new FqName("kotlin.jvm.internal.EnhancedMutability");