From 20fb519f1af01c7a040c1a4f38c5103c627929d7 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 22 Nov 2019 14:15:08 +0300 Subject: [PATCH] PSI2IR: Generate IMPLICIT_NOTNULL casts for platform type values --- .../kotlin/fir/Fir2IrTextTestGenerated.java | 15 ++++++++++ .../transformations/InsertImplicitCasts.kt | 1 - .../kotlin/ir/types/impl/IrTypeBase.kt | 1 - .../kotlin/ir/util/TypeTranslator.kt | 14 ++++----- .../ir/irText/expressions/coercionToUnit.txt | 6 ++-- .../ir/irText/expressions/equals.fir.txt | 29 ++++++++++++++++++ .../testData/ir/irText/expressions/equals.kt | 12 ++++++++ .../testData/ir/irText/expressions/equals.txt | 30 +++++++++++++++++++ .../implicitCastOnPlatformType.fir.txt | 2 +- .../implicitCastOnPlatformType.txt | 5 ++-- ...itNotNullInDestructuringAssignment.fir.txt | 21 +++++++++++++ ...mplicitNotNullInDestructuringAssignment.kt | 15 ++++++++++ ...plicitNotNullInDestructuringAssignment.txt | 23 ++++++++++++++ .../jvmStaticFieldReference.fir.txt | 14 ++++----- .../expressions/jvmStaticFieldReference.txt | 15 ++++++---- .../expressions/sam/samConstructors.txt | 6 ++-- .../sam/samConversionsWithSmartCasts.txt | 7 +++-- ...ndCompareToCallsOnPlatformTypeReceiver.txt | 30 +++++++++++-------- .../implicitNotNullOnPlatformType.fir.txt | 10 +++++++ .../types/implicitNotNullOnPlatformType.kt | 13 ++++++++ .../types/implicitNotNullOnPlatformType.txt | 12 ++++++++ ...ullabilityAssertionOnExtensionReceiver.txt | 6 ++-- .../ir/irText/types/platformTypeReceiver.txt | 6 ++-- .../smartCastOnFieldReceiverOfGenericType.txt | 5 ++-- .../kotlin/ir/IrTextTestCaseGenerated.java | 15 ++++++++++ 25 files changed, 264 insertions(+), 49 deletions(-) create mode 100644 compiler/testData/ir/irText/expressions/equals.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/equals.kt create mode 100644 compiler/testData/ir/irText/expressions/equals.txt create mode 100644 compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt create mode 100644 compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.txt create mode 100644 compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt create mode 100644 compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt create mode 100644 compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt 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 ff09f5b09cb..fcaa91b7935 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -861,6 +861,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/equality.kt"); } + @TestMetadata("equals.kt") + public void testEquals() throws Exception { + runTest("compiler/testData/ir/irText/expressions/equals.kt"); + } + @TestMetadata("extFunInvokeAsFun.kt") public void testExtFunInvokeAsFun() throws Exception { runTest("compiler/testData/ir/irText/expressions/extFunInvokeAsFun.kt"); @@ -946,6 +951,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt"); } + @TestMetadata("implicitNotNullInDestructuringAssignment.kt") + public void testImplicitNotNullInDestructuringAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt"); + } + @TestMetadata("in.kt") public void testIn() throws Exception { runTest("compiler/testData/ir/irText/expressions/in.kt"); @@ -1670,6 +1680,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt"); } + @TestMetadata("implicitNotNullOnPlatformType.kt") + public void testImplicitNotNullOnPlatformType() throws Exception { + runTest("compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt"); + } + @TestMetadata("intersectionType1_NI.kt") public void testIntersectionType1_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt"); diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt index 6cd18717bbe..4ad58124c07 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt @@ -32,7 +32,6 @@ import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.impl.originalKotlinType import org.jetbrains.kotlin.ir.util.TypeTranslator import org.jetbrains.kotlin.ir.util.coerceToUnitIfNeeded -import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.psi2ir.containsNull import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt index af1283a9bd7..b484bae7f40 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/impl/IrTypeBase.kt @@ -5,7 +5,6 @@ package org.jetbrains.kotlin.ir.types.impl -import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrConstructorCall import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.types.KotlinType 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 6dea47bb11f..0cb9083d830 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 @@ -59,18 +59,18 @@ class TypeTranslator( ?: symbolTable.referenceTypeParameter(typeParameterDescriptor) fun translateType(kotlinType: KotlinType): IrType = - translateType(kotlinType, Variance.INVARIANT).type + translateType(kotlinType, kotlinType, Variance.INVARIANT).type - private fun translateType(kotlinType: KotlinType, variance: Variance): IrTypeProjection { + private fun translateType(kotlinType: KotlinType, approximatedKotlinType: KotlinType, variance: Variance): IrTypeProjection { val approximatedType = LegacyTypeApproximation().approximate(kotlinType) when { approximatedType.isError -> - return IrErrorTypeImpl(approximatedType, translateTypeAnnotations(approximatedType.annotations), variance) + return IrErrorTypeImpl(approximatedKotlinType, translateTypeAnnotations(approximatedType.annotations), variance) approximatedType.isDynamic() -> - return IrDynamicTypeImpl(approximatedType, translateTypeAnnotations(approximatedType.annotations), variance) + return IrDynamicTypeImpl(approximatedKotlinType, translateTypeAnnotations(approximatedType.annotations), variance) approximatedType.isFlexible() -> - return translateType(approximatedType.upperIfFlexible(), variance) + return translateType(approximatedType.upperIfFlexible(), approximatedType, variance) } val ktTypeConstructor = approximatedType.constructor @@ -78,7 +78,7 @@ class TypeTranslator( ?: throw AssertionError("No descriptor for type $approximatedType") return IrSimpleTypeBuilder().apply { - this.kotlinType = kotlinType + this.kotlinType = approximatedKotlinType hasQuestionMark = approximatedType.isMarkedNullable this.variance = variance this.abbreviation = approximatedType.getAbbreviation()?.toIrTypeAbbreviation() @@ -154,6 +154,6 @@ class TypeTranslator( if (it.isStarProjection) IrStarProjectionImpl else - translateType(it.type, it.projectionKind) + translateType(it.type, it.type, it.projectionKind) } } diff --git a/compiler/testData/ir/irText/expressions/coercionToUnit.txt b/compiler/testData/ir/irText/expressions/coercionToUnit.txt index bb5272a5955..c401823214f 100644 --- a/compiler/testData/ir/irText/expressions/coercionToUnit.txt +++ b/compiler/testData/ir/irText/expressions/coercionToUnit.txt @@ -34,7 +34,8 @@ FILE fqName: fileName:/coercionToUnit.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_VAR 'val tmp_0: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_VAR 'val tmp_0: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null p0: CONST String type=kotlin.String value="Hello," TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Unit? origin=SAFE_CALL @@ -49,5 +50,6 @@ FILE fqName: fileName:/coercionToUnit.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_VAR 'val tmp_1: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_VAR 'val tmp_1: java.io.PrintStream? [val] declared in .test3' type=java.io.PrintStream? origin=null p0: CONST String type=kotlin.String value="world!" diff --git a/compiler/testData/ir/irText/expressions/equals.fir.txt b/compiler/testData/ir/irText/expressions/equals.fir.txt new file mode 100644 index 00000000000..da35af23b2e --- /dev/null +++ b/compiler/testData/ir/irText/expressions/equals.fir.txt @@ -0,0 +1,29 @@ +FILE fqName: fileName:/equals.kt + FUN name:testEqeq visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean + VALUE_PARAMETER name:a index:0 type:kotlin.Int + VALUE_PARAMETER name:b index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testEqeq (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in ' + CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'a: kotlin.Int declared in .testEqeq' type=kotlin.Int origin=null + arg1: GET_VAR 'b: kotlin.Int declared in .testEqeq' type=kotlin.Int origin=null + FUN name:testEquals visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean + VALUE_PARAMETER name:a index:0 type:kotlin.Int + VALUE_PARAMETER name:b index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testEquals (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in ' + CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any' type=kotlin.Boolean origin=null + $this: GET_VAR 'a: kotlin.Int declared in .testEquals' type=kotlin.Int origin=null + other: GET_VAR 'b: kotlin.Int declared in .testEquals' type=kotlin.Int origin=null + FUN name:testJEqeqNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testJEqeqNull (): kotlin.Boolean declared in ' + CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY + arg1: CONST Null type=kotlin.Nothing? value=null + FUN name:testJEqualsNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testJEqualsNull (): kotlin.Boolean declared in ' + CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any' type=kotlin.Boolean origin=null + $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY + other: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/expressions/equals.kt b/compiler/testData/ir/irText/expressions/equals.kt new file mode 100644 index 00000000000..4496b90a6da --- /dev/null +++ b/compiler/testData/ir/irText/expressions/equals.kt @@ -0,0 +1,12 @@ +// FILE: equals.kt + +fun testEqeq(a: Int, b: Int) = a == b +fun testEquals(a: Int, b: Int) = a.equals(b) + +fun testJEqeqNull() = J.INT_NULL == null +fun testJEqualsNull() = J.INT_NULL.equals(null) + +// FILE: J.java +public class J { + public static Integer INT_NULL = null; +} diff --git a/compiler/testData/ir/irText/expressions/equals.txt b/compiler/testData/ir/irText/expressions/equals.txt new file mode 100644 index 00000000000..9eb66012e45 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/equals.txt @@ -0,0 +1,30 @@ +FILE fqName: fileName:/equals.kt + FUN name:testEqeq visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean + VALUE_PARAMETER name:a index:0 type:kotlin.Int + VALUE_PARAMETER name:b index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testEqeq (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in ' + CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'a: kotlin.Int declared in .testEqeq' type=kotlin.Int origin=null + arg1: GET_VAR 'b: kotlin.Int declared in .testEqeq' type=kotlin.Int origin=null + FUN name:testEquals visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean + VALUE_PARAMETER name:a index:0 type:kotlin.Int + VALUE_PARAMETER name:b index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testEquals (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in ' + CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override] declared in kotlin.Int' type=kotlin.Boolean origin=null + $this: GET_VAR 'a: kotlin.Int declared in .testEquals' type=kotlin.Int origin=null + other: GET_VAR 'b: kotlin.Int declared in .testEquals' type=kotlin.Int origin=null + FUN name:testJEqeqNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testJEqeqNull (): kotlin.Boolean declared in ' + CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY + arg1: CONST Null type=kotlin.Nothing? value=null + FUN name:testJEqualsNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testJEqualsNull (): kotlin.Boolean declared in ' + CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override] declared in kotlin.Int' type=kotlin.Boolean origin=null + $this: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY + other: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.txt b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.txt index a55b0587cc6..f7841f19a32 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.txt @@ -2,5 +2,5 @@ FILE fqName: fileName:/implicitCastOnPlatformType.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (): kotlin.String declared in ' - CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? [operator] declared in java.lang.System' type=kotlin.String? origin=null + CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null p0: CONST String type=kotlin.String value="test" diff --git a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.txt b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.txt index f7841f19a32..48a7778edda 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.txt @@ -2,5 +2,6 @@ FILE fqName: fileName:/implicitCastOnPlatformType.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test (): kotlin.String declared in ' - CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null - p0: CONST String type=kotlin.String value="test" + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null + p0: CONST String type=kotlin.String value="test" diff --git a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.txt b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.txt new file mode 100644 index 00000000000..35ec0f8def1 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/implicitNotNullInDestructuringAssignment.kt + FUN name:component1 visibility:public modality:FINAL <> ($receiver:.J?) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name: type:.J? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + FUN name:component2 visibility:private modality:FINAL <> ($receiver:.J) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name: type:.J + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun component2 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=2 + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.J? [val] + CALL 'public open fun j (): .J? declared in .J' type=.J? origin=null + VAR name:a type:kotlin.Int [val] + CALL 'public final fun component1 (): kotlin.Int declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_0: .J? [val] declared in .test' type=.J? origin=null + VAR name:b type:kotlin.Int [val] + CALL 'private final fun component2 (): kotlin.Int declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'val tmp_0: .J? [val] declared in .test' type=.J? origin=null diff --git a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt new file mode 100644 index 00000000000..e5d03aa8dd8 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt @@ -0,0 +1,15 @@ +// FILE: implicitNotNullInDestructuringAssignment.kt + +// NB extension receiver is nullable +operator fun J?.component1() = 1 + +private operator fun J.component2() = 2 + +fun test() { + val (a, b) = J.j() +} + +// FILE: J.java +public class J { + public static J j() { return null; } +} diff --git a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.txt b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.txt new file mode 100644 index 00000000000..c628b7c64b0 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.txt @@ -0,0 +1,23 @@ +FILE fqName: fileName:/implicitNotNullInDestructuringAssignment.kt + FUN name:component1 visibility:public modality:FINAL <> ($receiver:.J?) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name: type:.J? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + FUN name:component2 visibility:private modality:FINAL <> ($receiver:.J) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name: type:.J + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun component2 (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=2 + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.J? [val] + CALL 'public open fun j (): .J? declared in .J' type=.J? origin=null + VAR name:a type:kotlin.Int [val] + CALL 'public final fun component1 (): kotlin.Int declared in ' type=kotlin.Int origin=COMPONENT_N(index=1) + $receiver: GET_VAR 'val tmp_0: .J? [val] declared in .test' type=.J? origin=null + VAR name:b type:kotlin.Int [val] + CALL 'private final fun component2 (): kotlin.Int declared in ' type=kotlin.Int origin=COMPONENT_N(index=2) + $receiver: TYPE_OP type=.J origin=IMPLICIT_NOTNULL typeOperand=.J + GET_VAR 'val tmp_0: .J? [val] declared in .test' type=.J? origin=null diff --git a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.fir.txt b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.fir.txt index 3959cac1690..661b0b62033 100644 --- a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.fir.txt @@ -1,14 +1,14 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt FUN name:testFun visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null + CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="testFun" PROPERTY name:testProp visibility:public modality:FINAL [var] FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Any correspondingProperty: PROPERTY name:testProp visibility:public modality:FINAL [var] BLOCK_BODY - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null + CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="testProp/get" RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' @@ -17,7 +17,7 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt correspondingProperty: PROPERTY name:testProp visibility:public modality:FINAL [var] VALUE_PARAMETER name:value index:0 type:kotlin.Any BLOCK_BODY - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null + CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="testProp/set" CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any] @@ -33,7 +33,7 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: BLOCK type=kotlin.Int origin=null - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null + CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="TestClass/test" CONST Int type=kotlin.Int value=42 @@ -46,12 +46,12 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt receiver: GET_VAR ': .TestClass declared in .TestClass.' type=.TestClass origin=null ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY - CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null + CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="TestClass/init" - FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override] overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + public open fun equals (other: kotlin.Any?): kotlin.Boolean 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] diff --git a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt index c69ba673c96..941214d83d4 100644 --- a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt +++ b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt @@ -2,14 +2,16 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt FUN name:testFun visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="testFun" PROPERTY name:testProp visibility:public modality:FINAL [var] FUN name: visibility:public modality:FINAL <> () returnType:kotlin.Any correspondingProperty: PROPERTY name:testProp visibility:public modality:FINAL [var] BLOCK_BODY CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="testProp/get" RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in ' CONST Int type=kotlin.Int value=42 @@ -18,7 +20,8 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt VALUE_PARAMETER name:value index:0 type:kotlin.Any BLOCK_BODY CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="testProp/set" CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestClass @@ -34,7 +37,8 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt if: CONST Boolean type=kotlin.Boolean value=true then: BLOCK type=kotlin.Int origin=null CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="TestClass/test" CONST Int type=kotlin.Int value=42 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestClass) returnType:kotlin.Int @@ -47,7 +51,8 @@ FILE fqName: fileName:/jvmStaticFieldReference.kt ANONYMOUS_INITIALIZER isStatic=false BLOCK_BODY CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY + $this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY p0: CONST String type=kotlin.String value="TestClass/init" FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.txt index 00b8b50867a..7e2dadf931a 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.txt @@ -32,5 +32,7 @@ FILE fqName: fileName:/samConstructors.kt BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (a: kotlin.Int?, b: kotlin.Int?): kotlin.Int declared in .test4' CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS - $this: GET_VAR 'a: kotlin.Int? declared in .test4.' type=kotlin.Int? origin=null - other: GET_VAR 'b: kotlin.Int? declared in .test4.' type=kotlin.Int? origin=null + $this: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int + GET_VAR 'a: kotlin.Int? declared in .test4.' type=kotlin.Int? origin=null + other: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int + GET_VAR 'b: kotlin.Int? declared in .test4.' type=kotlin.Int? origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt index 482ef05a250..0f5bf3614fe 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt @@ -106,9 +106,10 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .J' type=.J origin=null r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - CALL 'public open fun id (x: T of .J.id?): T of .J.id? declared in .J' type=kotlin.Function0? origin=null - : kotlin.Function0? - x: GET_VAR 'a: kotlin.Function0 declared in .test8' type=kotlin.Function0 origin=null + TYPE_OP type=kotlin.Function0 origin=IMPLICIT_NOTNULL typeOperand=kotlin.Function0 + CALL 'public open fun id (x: T of .J.id?): T of .J.id? declared in .J' type=kotlin.Function0? origin=null + : kotlin.Function0? + x: GET_VAR 'a: kotlin.Function0 declared in .test8' type=kotlin.Function0 origin=null FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null diff --git a/compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.txt b/compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.txt index 2e3c14c17b6..399287b11da 100644 --- a/compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.txt +++ b/compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.txt @@ -4,8 +4,9 @@ FILE fqName: fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testPlatformEqualsPlatform (): kotlin.Boolean declared in ' CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Double' type=kotlin.Boolean origin=null - $this: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null - $this: GET_VAR ': .JavaClass declared in .testPlatformEqualsPlatform' type=.JavaClass origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double + CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null + $this: GET_VAR ': .JavaClass declared in .testPlatformEqualsPlatform' type=.JavaClass origin=null other: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null $this: GET_VAR ': .JavaClass declared in .testPlatformEqualsPlatform' type=.JavaClass origin=null FUN name:testPlatformEqualsKotlin visibility:public modality:FINAL <> ($receiver:.JavaClass) returnType:kotlin.Boolean @@ -13,8 +14,9 @@ FILE fqName: fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testPlatformEqualsKotlin (): kotlin.Boolean declared in ' CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Double' type=kotlin.Boolean origin=null - $this: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null - $this: GET_VAR ': .JavaClass declared in .testPlatformEqualsKotlin' type=.JavaClass origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double + CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null + $this: GET_VAR ': .JavaClass declared in .testPlatformEqualsKotlin' type=.JavaClass origin=null other: CONST Double type=kotlin.Double value=0.0 FUN name:testKotlinEqualsPlatform visibility:public modality:FINAL <> ($receiver:.JavaClass) returnType:kotlin.Boolean $receiver: VALUE_PARAMETER name: type:.JavaClass @@ -29,17 +31,20 @@ FILE fqName: fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testPlatformCompareToPlatform (): kotlin.Int declared in ' CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Double' type=kotlin.Int origin=null - $this: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null - $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToPlatform' type=.JavaClass origin=null - other: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null - $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToPlatform' type=.JavaClass origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double + CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null + $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToPlatform' type=.JavaClass origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double + CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null + $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToPlatform' type=.JavaClass origin=null FUN name:testPlatformCompareToKotlin visibility:public modality:FINAL <> ($receiver:.JavaClass) returnType:kotlin.Int $receiver: VALUE_PARAMETER name: type:.JavaClass BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testPlatformCompareToKotlin (): kotlin.Int declared in ' CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Double' type=kotlin.Int origin=null - $this: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null - $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToKotlin' type=.JavaClass origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double + CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null + $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToKotlin' type=.JavaClass origin=null other: CONST Double type=kotlin.Double value=0.0 FUN name:testKotlinCompareToPlatform visibility:public modality:FINAL <> ($receiver:.JavaClass) returnType:kotlin.Int $receiver: VALUE_PARAMETER name: type:.JavaClass @@ -47,5 +52,6 @@ FILE fqName: fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv RETURN type=kotlin.Nothing from='public final fun testKotlinCompareToPlatform (): kotlin.Int declared in ' CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Double' type=kotlin.Int origin=null $this: CONST Double type=kotlin.Double value=0.0 - other: CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null - $this: GET_VAR ': .JavaClass declared in .testKotlinCompareToPlatform' type=.JavaClass origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double + CALL 'public open fun null0 (): kotlin.Double? declared in .JavaClass' type=kotlin.Double? origin=null + $this: GET_VAR ': .JavaClass declared in .testKotlinCompareToPlatform' type=.JavaClass origin=null diff --git a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt new file mode 100644 index 00000000000..44de0e68670 --- /dev/null +++ b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.fir.txt @@ -0,0 +1,10 @@ +FILE fqName: fileName:/implicitNotNullOnPlatformType.kt + FUN name:f visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + s: CALL 'public open fun s (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + s: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt new file mode 100644 index 00000000000..82593a33b1b --- /dev/null +++ b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt @@ -0,0 +1,13 @@ +// FILE: implicitNotNullOnPlatformType.kt +fun f(s: String) {} + +fun test() { + f(J.s()) + f(J.STRING) +} + +// FILE: J.java +public class J { + public static String STRING = s(); + public static String s() { return null; } +} diff --git a/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt new file mode 100644 index 00000000000..5c6560262d5 --- /dev/null +++ b/compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.txt @@ -0,0 +1,12 @@ +FILE fqName: fileName:/implicitNotNullOnPlatformType.kt + FUN name:f visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun f (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 s (): kotlin.String? declared in .J' type=kotlin.String? origin=null + CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in ' type=kotlin.Unit origin=null + s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.txt b/compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.txt index 5606e1b25d3..e9ca8d32ba0 100644 --- a/compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.txt +++ b/compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.txt @@ -28,10 +28,12 @@ FILE fqName: fileName:/nullabilityAssertionOnExtensionReceiver.kt FUN name:testExt visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun extension (): kotlin.Unit declared in ' type=kotlin.Unit origin=null - $receiver: CALL 'public open fun s (): kotlin.String? declared in .J' type=kotlin.String? origin=null + $receiver: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun s (): kotlin.String? declared in .J' type=kotlin.String? origin=null FUN name:testMemberExt visibility:public modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.C BLOCK_BODY CALL 'public final fun memberExtension (): kotlin.Unit declared in .C' type=kotlin.Unit origin=null $this: GET_VAR ': .C declared in .testMemberExt' type=.C origin=null - $receiver: CALL 'public open fun s (): kotlin.String? declared in .J' type=kotlin.String? origin=null + $receiver: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun s (): kotlin.String? declared in .J' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/platformTypeReceiver.txt b/compiler/testData/ir/irText/types/platformTypeReceiver.txt index a95f15b79e0..8c4e618ba4b 100644 --- a/compiler/testData/ir/irText/types/platformTypeReceiver.txt +++ b/compiler/testData/ir/irText/types/platformTypeReceiver.txt @@ -3,11 +3,13 @@ FILE fqName: fileName:/platformTypeReceiver.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Boolean declared in ' CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null - $this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:BOOL_NULL type:kotlin.Boolean? visibility:public [static]' type=kotlin.Boolean? origin=GET_PROPERTY + $this: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_NOTNULL typeOperand=kotlin.Boolean + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:BOOL_NULL type:kotlin.Boolean? visibility:public [static]' type=kotlin.Boolean? origin=GET_PROPERTY other: CONST Null type=kotlin.Nothing? value=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Boolean BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Boolean declared in ' CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null - $this: CALL 'public open fun boolNull (): kotlin.Boolean? declared in .J' type=kotlin.Boolean? origin=null + $this: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_NOTNULL typeOperand=kotlin.Boolean + CALL 'public open fun boolNull (): kotlin.Boolean? declared in .J' type=kotlin.Boolean? origin=null other: CONST Null type=kotlin.Nothing? value=null diff --git a/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.txt b/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.txt index 98641c7d646..813daee3473 100644 --- a/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.txt +++ b/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.txt @@ -20,5 +20,6 @@ FILE fqName: fileName:/smartCastOnFieldReceiverOfGenericType.kt TYPE_OP type=.JCell origin=CAST typeOperand=.JCell GET_VAR 'a: kotlin.Any declared in .testGetField' type=kotlin.Any origin=null RETURN type=kotlin.Nothing from='public final fun testGetField (a: kotlin.Any): kotlin.String declared in ' - GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:T of .JCell? visibility:public' type=kotlin.String? origin=GET_PROPERTY - receiver: GET_VAR 'a: kotlin.Any declared in .testGetField' type=kotlin.Any origin=null + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:T of .JCell? visibility:public' type=kotlin.String? origin=GET_PROPERTY + receiver: GET_VAR 'a: kotlin.Any declared in .testGetField' type=kotlin.Any origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index bb6be31b0ae..6c633f247ed 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -861,6 +861,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/equality.kt"); } + @TestMetadata("equals.kt") + public void testEquals() throws Exception { + runTest("compiler/testData/ir/irText/expressions/equals.kt"); + } + @TestMetadata("extFunInvokeAsFun.kt") public void testExtFunInvokeAsFun() throws Exception { runTest("compiler/testData/ir/irText/expressions/extFunInvokeAsFun.kt"); @@ -946,6 +951,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt"); } + @TestMetadata("implicitNotNullInDestructuringAssignment.kt") + public void testImplicitNotNullInDestructuringAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt"); + } + @TestMetadata("in.kt") public void testIn() throws Exception { runTest("compiler/testData/ir/irText/expressions/in.kt"); @@ -1670,6 +1680,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt"); } + @TestMetadata("implicitNotNullOnPlatformType.kt") + public void testImplicitNotNullOnPlatformType() throws Exception { + runTest("compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt"); + } + @TestMetadata("intersectionType1_NI.kt") public void testIntersectionType1_NI() throws Exception { runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");