From badfade2fd6bce88434f176d2adc7cea473c0500 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 23 Nov 2021 18:56:53 +0300 Subject: [PATCH] FIR2IR strip FlexibleNullability on IMPLICIT_NOTNULL --- .../fir/backend/Fir2IrImplicitCastInserter.kt | 5 +- .../runners/ir/Fir2IrTextTestGenerated.java | 12 +++ .../box/notNullAssertions/callAssertions.kt | 30 +++---- .../implicitCastOnPlatformType.fir.ir.txt | 7 -- .../implicitCastOnPlatformType.fir.kt.txt | 3 - .../expressions/implicitCastOnPlatformType.kt | 1 + ...otNullInDestructuringAssignment.fir.ir.txt | 2 +- ...otNullInDestructuringAssignment.fir.kt.txt | 3 +- .../nullCheckOnLambdaReturn.fir.ir.txt | 2 +- .../nullCheckOnLambdaReturn.fir.kt.txt | 2 +- .../sam/genericSamSmartcast.fir.ir.txt | 2 +- .../sam/genericSamSmartcast.fir.kt.txt | 3 +- .../sam/samConstructors.fir.ir.txt | 2 +- .../sam/samConstructors.fir.kt.txt | 3 +- .../ir/irText/firProblems/JCTree.fir.ir.txt | 2 +- .../ir/irText/firProblems/JCTree.fir.kt.txt | 3 +- ...bilityInDestructuringAssignment.fir.ir.txt | 2 +- ...bilityInDestructuringAssignment.fir.kt.txt | 2 +- ...reToCallsOnPlatformTypeReceiver.fir.ir.txt | 4 +- ...reToCallsOnPlatformTypeReceiver.fir.kt.txt | 5 +- .../implicitNotNullOnPlatformType.fir.ir.txt | 6 +- .../implicitNotNullOnPlatformType.fir.kt.txt | 6 +- .../nullCheckOnInterfaceDelegation.fir.ir.txt | 87 ++++++++++++++++++ .../nullCheckOnInterfaceDelegation.fir.kt.txt | 41 +++++++++ .../nullCheckOnInterfaceDelegation.ir.txt | 88 +++++++++++++++++++ .../nullCheckOnInterfaceDelegation.kt | 22 +++++ .../nullCheckOnInterfaceDelegation.kt.txt | 40 +++++++++ .../stringVsAny.ir.txt | 17 ++++ .../nullCheckOnLambdaResult/stringVsAny.kt | 22 +++++ .../stringVsAny.kt.txt | 11 +++ .../stringVsTConstrained.fir.ir.txt | 22 ----- .../stringVsTConstrained.fir.kt.txt | 10 --- .../stringVsTConstrained.kt | 1 + ...ityAssertionOnExtensionReceiver.fir.ir.txt | 39 -------- ...ityAssertionOnExtensionReceiver.fir.kt.txt | 22 ----- ...nullabilityAssertionOnExtensionReceiver.kt | 1 + ...xedNullableAndNotNullableBounds.fir.ir.txt | 4 +- ...xedNullableAndNotNullableBounds.fir.kt.txt | 5 +- ...erWithMultipleNotNullableBounds.fir.ir.txt | 4 +- ...erWithMultipleNotNullableBounds.fir.kt.txt | 5 +- ...astOnFieldReceiverOfGenericType.fir.ir.txt | 2 +- ...astOnFieldReceiverOfGenericType.fir.kt.txt | 3 +- .../test/runners/ir/IrTextTestGenerated.java | 12 +++ 43 files changed, 414 insertions(+), 151 deletions(-) delete mode 100644 compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.kt.txt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.kt.txt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.ir.txt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.ir.txt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt create mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt delete mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.kt.txt delete mode 100644 compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.ir.txt delete mode 100644 compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.kt.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index e98d8d527a3..d407dc85362 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.classId import org.jetbrains.kotlin.ir.util.parentAsClass +import org.jetbrains.kotlin.name.StandardClassIds import org.jetbrains.kotlin.types.AbstractTypeChecker class Fir2IrImplicitCastInserter( @@ -232,7 +233,9 @@ class Fir2IrImplicitCastInserter( // Cast type massage 1. Remove @EnhancedNullability // Cast type massage 2. Convert it to a non-null variant (in case of @FlexibleNullability) val castType = type.removeAnnotations { - it.symbol.owner.parentAsClass.classId == CompilerConeAttributes.EnhancedNullability.ANNOTATION_CLASS_ID + val classId = it.symbol.owner.parentAsClass.classId + classId == StandardClassIds.Annotations.EnhancedNullability || + classId == StandardClassIds.Annotations.FlexibleNullability }.withHasQuestionMark(false) return IrTypeOperatorCallImpl( this.startOffset, diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 715edfc9f3e..f0f4d5e21aa 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -2901,6 +2901,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.kt"); } + @Test + @TestMetadata("nullCheckOnInterfaceDelegation.kt") + public void testNullCheckOnInterfaceDelegation() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt"); + } + @Test @TestMetadata("nullabilityAssertionOnExtensionReceiver.kt") public void testNullabilityAssertionOnExtensionReceiver() throws Exception { @@ -2970,6 +2976,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt"); } + @Test + @TestMetadata("stringVsAny.kt") + public void testStringVsAny() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt"); + } + @Test @TestMetadata("stringVsT.kt") public void testStringVsT() throws Exception { diff --git a/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt b/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt index d0763812793..b67724274f0 100644 --- a/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt +++ b/compiler/testData/codegen/box/notNullAssertions/callAssertions.kt @@ -77,48 +77,48 @@ fun checkAssertions(illegalStateExpected: Boolean) { val check = AssertionChecker(illegalStateExpected) // simple call - check("foo") { A().foo() } + check("A::foo") { A().foo() } // simple static call - check("staticFoo") { A.staticFoo() } + check("A::staticFoo") { A.staticFoo() } - // supercall - check("foo") { Derived().foo() } + // super call + check("Derived::foo") { Derived().foo() } // delegated call - check("foo") { Delegated().foo() } + check("Delegated::foo") { Delegated().foo() } // collection element - check("get") { A()[""] } + check("A::get") { A()[""] } // binary expression - check("plus") { A() + A() } + check("A::plus") { A() + A() } // field - check("NULL") { A().NULL } + check("A::NULL") { A().NULL } // static field - check("STATIC_NULL") { A.STATIC_NULL } + check("A::STATIC_NULL") { A.STATIC_NULL } // postfix expression // TODO: -// check("inc") { var a = A().a(); a++ } +// check("A::inc") { var a = A().a(); a++ } // prefix expression - check("inc-b") { var a = A.B.b(); a++ } + check("A::inc-b") { var a = A.B.b(); a++ } // prefix expression - check("inc-c") { var a = A.C.c(); a++ } + check("A::inc-c") { var a = A.C.c(); a++ } // prefix expression - check("inc") { var a = A().a(); ++a } + check("A::inc") { var a = A().a(); ++a } // prefix expression - check("inc-b") { var a = A.B.b(); ++a } + check("A::inc-b") { var a = A.B.b(); ++a } // prefix expression // TODO: -// check("inc-c") { var a = A.C.c(); ++a } +// check("A::inc-c") { var a = A.C.c(); ++a } } operator fun A.C.inc(): A.C = A.C() diff --git a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.ir.txt b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.ir.txt deleted file mode 100644 index 457c4ac2180..00000000000 --- a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.ir.txt +++ /dev/null @@ -1,7 +0,0 @@ -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 ' - TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String - CALL 'public open fun getProperty (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] kotlin.String? declared in java.lang.System' type=@[FlexibleNullability] kotlin.String? origin=null - p0: CONST String type=kotlin.String value="test" diff --git a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.kt.txt b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.kt.txt deleted file mode 100644 index 157743618e3..00000000000 --- a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.fir.kt.txt +++ /dev/null @@ -1,3 +0,0 @@ -fun test(): String { - return getProperty(p0 = "test") /*!! @FlexibleNullability String */ -} diff --git a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.kt b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.kt index 03c99a33855..6f986b4bf6a 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.kt +++ b/compiler/testData/ir/irText/expressions/implicitCastOnPlatformType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // TARGET_BACKEND: JVM fun test(): String = System.getProperty("test") \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.ir.txt b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.ir.txt index 53d49328bdc..9663f05cd8c 100644 --- a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.ir.txt @@ -18,5 +18,5 @@ FILE fqName: fileName:/implicitNotNullInDestructuringAssignment.kt $receiver: GET_VAR 'val tmp_0: @[FlexibleNullability] .J? [val] declared in .test' type=@[FlexibleNullability] .J? origin=null VAR name:b type:kotlin.Int [val] CALL 'private final fun component2 (): kotlin.Int [operator] declared in ' type=kotlin.Int origin=COMPONENT_N(index=2) - $receiver: TYPE_OP type=@[FlexibleNullability] .J origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] .J + $receiver: TYPE_OP type=.J origin=IMPLICIT_NOTNULL typeOperand=.J GET_VAR 'val tmp_0: @[FlexibleNullability] .J? [val] declared in .test' type=@[FlexibleNullability] .J? origin=null diff --git a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.kt.txt b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.kt.txt index 41cb0277b1c..d8f507a0cca 100644 --- a/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.fir.kt.txt @@ -9,5 +9,6 @@ private operator fun J.component2(): Int { fun test() { val : @FlexibleNullability J? = j() val a: Int = .component1() - val b: Int = /*!! @FlexibleNullability J */.component2() + val b: Int = /*!! J */.component2() } + diff --git a/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.ir.txt b/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.ir.txt index e5bb53a461d..5c13ecdcdd2 100644 --- a/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.ir.txt @@ -25,7 +25,7 @@ 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 .test1' - TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function0 visibility:private [final,static] diff --git a/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.kt.txt b/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.kt.txt index 0a86a34fd77..851a911a784 100644 --- a/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/nullCheckOnLambdaReturn.fir.kt.txt @@ -12,7 +12,7 @@ fun id(x: T): T { fun test1(): Any { return checkAny(fn = local fun (): Any { - return foo() /*!! @FlexibleNullability String */ + return foo() /*!! String */ } ) } diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt index c8d985a7f98..a46a31f6bf2 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.ir.txt @@ -7,7 +7,7 @@ FILE fqName: fileName:/genericSamSmartcast.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.A<*> GET_VAR 'x: kotlin.Any declared in .f' type=kotlin.Any origin=null then: RETURN type=kotlin.Nothing from='public final fun f (x: kotlin.Any): kotlin.String declared in ' - TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun call (block: @[FlexibleNullability] .A.I<@[FlexibleNullability] T of .A?>?): @[FlexibleNullability] kotlin.String? declared in .A' type=@[FlexibleNullability] kotlin.String? origin=null $this: TYPE_OP type=.A<*> origin=IMPLICIT_CAST typeOperand=.A<*> GET_VAR 'x: kotlin.Any declared in .f' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt index 2a329293504..a8e42e83cea 100644 --- a/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/genericSamSmartcast.fir.kt.txt @@ -3,7 +3,8 @@ fun f(x: Any): String { x is A<*> -> return x /*as A<*> */.call(block = local fun (y: Any?): @FlexibleNullability String? { return "OK" } - /*-> @FlexibleNullability I<@FlexibleNullability Any?>? */) /*!! @FlexibleNullability String */ + /*-> @FlexibleNullability I<@FlexibleNullability Any?>? */) /*!! String */ } return "Fail" } + diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.ir.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.ir.txt index 1bee6c84bc8..5a8a356001d 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.ir.txt @@ -33,5 +33,5 @@ FILE fqName: fileName:/samConstructors.kt RETURN type=kotlin.Nothing from='local final fun (a: @[FlexibleNullability] kotlin.Int?, b: @[FlexibleNullability] 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: @[FlexibleNullability] kotlin.Int? declared in .test4.' type=@[FlexibleNullability] kotlin.Int? origin=null - other: TYPE_OP type=@[FlexibleNullability] kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.Int + other: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int GET_VAR 'b: @[FlexibleNullability] kotlin.Int? declared in .test4.' type=@[FlexibleNullability] kotlin.Int? origin=null diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.kt.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.kt.txt index 2e09526a136..0f97e07317a 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.kt.txt @@ -18,7 +18,8 @@ fun test3(): Runnable { fun test4(): Comparator<@FlexibleNullability Int?> { return local fun (a: @FlexibleNullability Int?, b: @FlexibleNullability Int?): Int { - return a.minus(other = b /*!! @FlexibleNullability Int */) + return a.minus(other = b /*!! Int */) } /*-> Comparator<@FlexibleNullability Int?> */ } + diff --git a/compiler/testData/ir/irText/firProblems/JCTree.fir.ir.txt b/compiler/testData/ir/irText/firProblems/JCTree.fir.ir.txt index 7c82ebc14ed..27556124e3e 100644 --- a/compiler/testData/ir/irText/firProblems/JCTree.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/JCTree.fir.ir.txt @@ -31,7 +31,7 @@ FILE fqName: fileName:/JCTreeUser.kt if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=.JCTree.JCTypeApply GET_VAR 'var tree: .JCTree [var] declared in .Owner.' type=.JCTree origin=null then: RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Owner' - TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:clazz type:@[FlexibleNullability] kotlin.String? visibility:public' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY receiver: TYPE_OP type=.JCTree.JCTypeApply origin=IMPLICIT_CAST typeOperand=.JCTree.JCTypeApply GET_VAR 'var tree: .JCTree [var] declared in .Owner.' type=.JCTree origin=null diff --git a/compiler/testData/ir/irText/firProblems/JCTree.fir.kt.txt b/compiler/testData/ir/irText/firProblems/JCTree.fir.kt.txt index d0640c6e42f..d7e07480e29 100644 --- a/compiler/testData/ir/irText/firProblems/JCTree.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/JCTree.fir.kt.txt @@ -13,9 +13,10 @@ class Owner { get(): String { var tree: JCTree = .() when { - tree is JCTypeApply -> return tree /*as JCTypeApply */.#clazz /*!! @FlexibleNullability String */ + tree is JCTypeApply -> return tree /*as JCTypeApply */.#clazz /*!! String */ } return "" } } + diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.ir.txt index 0ba2446cbdc..179dc386ead 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.ir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.ir.txt @@ -182,7 +182,7 @@ FILE fqName: fileName:/enhancedNullabilityInDestructuringAssignment.kt : kotlin.collections.IndexedValue<@[EnhancedNullability] .P> $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.Iterable.P>> origin=null : @[EnhancedNullability] .P - $receiver: TYPE_OP type=@[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] .P> + $receiver: TYPE_OP type=kotlin.collections.List<@[EnhancedNullability] .P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[EnhancedNullability] .P> CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] .P>? declared in .J' type=@[FlexibleNullability] kotlin.collections.List<@[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) diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.kt.txt index 7180281e9f4..777558a05de 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.kt.txt @@ -80,7 +80,7 @@ fun test3() { } fun test4() { - val : IndexedValue<@EnhancedNullability P> = listOfNotNull() /*!! @FlexibleNullability List<@EnhancedNullability P> */.withIndex<@EnhancedNullability P>().first>() + val : IndexedValue<@EnhancedNullability P> = listOfNotNull() /*!! List<@EnhancedNullability P> */.withIndex<@EnhancedNullability P>().first>() val x: Int = .component1() val y: @EnhancedNullability P = .component2() /*!! P */ use(x = x, y = y) diff --git a/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.ir.txt index 58cbf87ee63..b1f69cd9de6 100644 --- a/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.ir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.ir.txt @@ -31,7 +31,7 @@ FILE fqName: fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv 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 (): @[FlexibleNullability] kotlin.Double? declared in .JavaClass' type=@[FlexibleNullability] kotlin.Double? origin=null $this: GET_VAR ': .JavaClass declared in .testPlatformCompareToPlatform' type=.JavaClass origin=null - other: TYPE_OP type=@[FlexibleNullability] kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.Double + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double CALL 'public open fun null0 (): @[FlexibleNullability] kotlin.Double? declared in .JavaClass' type=@[FlexibleNullability] 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 @@ -48,6 +48,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: TYPE_OP type=@[FlexibleNullability] kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.Double + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double CALL 'public open fun null0 (): @[FlexibleNullability] kotlin.Double? declared in .JavaClass' type=@[FlexibleNullability] kotlin.Double? origin=null $this: GET_VAR ': .JavaClass declared in .testKotlinCompareToPlatform' type=.JavaClass origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.kt.txt index 25067da52db..4985c2b163c 100644 --- a/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.fir.kt.txt @@ -11,7 +11,7 @@ fun JavaClass.testKotlinEqualsPlatform(): Boolean { } fun JavaClass.testPlatformCompareToPlatform(): Int { - return .null0().compareTo(other = .null0() /*!! @FlexibleNullability Double */) + return .null0().compareTo(other = .null0() /*!! Double */) } fun JavaClass.testPlatformCompareToKotlin(): Int { @@ -19,5 +19,6 @@ fun JavaClass.testPlatformCompareToKotlin(): Int { } fun JavaClass.testKotlinCompareToPlatform(): Int { - return 0.0.compareTo(other = .null0() /*!! @FlexibleNullability Double */) + return 0.0.compareTo(other = .null0() /*!! Double */) } + diff --git a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.ir.txt index f1eb392895e..78f51eb064f 100644 --- a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.ir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.ir.txt @@ -65,10 +65,10 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt 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=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] 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=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY FUN name:testContains visibility:public modality:FINAL <> (m:.MySet) returnType:kotlin.Unit VALUE_PARAMETER name:m index:0 type:.MySet @@ -76,7 +76,7 @@ FILE fqName: fileName:/implicitNotNullOnPlatformType.kt TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in .MySet' type=kotlin.Boolean origin=null $this: GET_VAR 'm: .MySet declared in .testContains' type=.MySet origin=null - element: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + element: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in .MySet' type=kotlin.Boolean origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.kt.txt index fd1f87d63ca..cb7cf8d81b9 100644 --- a/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.fir.kt.txt @@ -32,11 +32,11 @@ class MySet : Set { } fun test() { - f(s = s() /*!! @FlexibleNullability String */) - f(s = #STRING /*!! @FlexibleNullability String */) + f(s = s() /*!! String */) + f(s = #STRING /*!! String */) } fun testContains(m: MySet) { - m.contains(element = #STRING /*!! @FlexibleNullability String */) /*~> Unit */ + m.contains(element = #STRING /*!! String */) /*~> Unit */ m.contains(element = "abc") /*~> Unit */ } diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt new file mode 100644 index 00000000000..41237287706 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.ir.txt @@ -0,0 +1,87 @@ +Module: lib +Module: main +FILE fqName: fileName:/nullCheckOnInterfaceDelegation.kt + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.IFoo + 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 + CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[.A; .IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived + CONSTRUCTOR visibility:public <> () returnType:.Derived [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[.A; .IFoo]' + FUN name:foo visibility:public modality:FINAL <> ($this:.Derived) returnType:@[FlexibleNullability] kotlin.String? + overridden: + public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .A + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.Derived + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (): @[FlexibleNullability] kotlin.String? declared in .Derived' + CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .A' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' type=@[FlexibleNullability] kotlin.String? origin=null + $this: GET_VAR ': .Derived declared in .Derived.foo' type=.Derived 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 .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo + $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 .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $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 .A + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Delegated + CONSTRUCTOR visibility:public <> () returnType:.Delegated [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[.IFoo]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Delegated) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.Delegated + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .Delegated' + CALL 'public abstract fun foo (): kotlin.String declared in .IFoo' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.IFoo visibility:local [final]' type=.IFoo origin=null + receiver: GET_VAR ': .Delegated declared in .Delegated.foo' type=.Delegated origin=null + FIELD DELEGATE name:<$$delegate_0> type:.IFoo visibility:local [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Derived' type=.Derived 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 .IFoo + $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 .IFoo + $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 .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + 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 ' + CALL 'public open fun foo (): kotlin.String declared in .Delegated' type=kotlin.String origin=null + $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Delegated' type=.Delegated origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.kt.txt new file mode 100644 index 00000000000..05a4544badf --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.fir.kt.txt @@ -0,0 +1,41 @@ +// MODULE: lib +// MODULE: main +// FILE: nullCheckOnInterfaceDelegation.kt + +interface IFoo { + abstract fun foo(): String + +} + +class Derived : A, IFoo { + constructor() /* primary */ { + super/*A*/() + /* () */ + + } + + override fun foo(): @FlexibleNullability String? { + return super.foo() + } + +} + +class Delegated : IFoo { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun foo(): String { + return .#<$$delegate_0>.foo() + } + + local /* final field */ val <$$delegate_0>: IFoo = Derived() + +} + +fun testReturnValue(): String { + return Delegated().foo() +} + diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.ir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.ir.txt new file mode 100644 index 00000000000..92c6048de26 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.ir.txt @@ -0,0 +1,88 @@ +Module: lib +Module: main +FILE fqName: fileName:/nullCheckOnInterfaceDelegation.kt + CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IFoo + FUN name:foo visibility:public modality:ABSTRACT <> ($this:.IFoo) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.IFoo + 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 + CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[.A; .IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Derived + CONSTRUCTOR visibility:public <> () returnType:.Derived [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[.A; .IFoo]' + FUN name:foo visibility:public modality:OPEN <> ($this:.Derived) returnType:@[FlexibleNullability] kotlin.String? + overridden: + public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .A + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.Derived + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .Derived' + CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .A' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' type=@[FlexibleNullability] kotlin.String? origin=null + $this: GET_VAR ': .Derived declared in .Derived.foo' type=.Derived 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 .A + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .IFoo + $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 .A + public open fun hashCode (): kotlin.Int [fake_override] declared in .IFoo + $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 .A + public open fun toString (): kotlin.String [fake_override] declared in .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[.IFoo] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Delegated + CONSTRUCTOR visibility:public <> () returnType:.Delegated [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[.IFoo]' + FIELD DELEGATE name:$$delegate_0 type:.Derived visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Derived' type=.Derived origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Delegated) returnType:kotlin.String + overridden: + public abstract fun foo (): kotlin.String declared in .IFoo + $this: VALUE_PARAMETER name: type:.Delegated + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .Delegated' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in .Derived' type=@[FlexibleNullability] kotlin.String? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.Derived visibility:private [final]' type=.Derived origin=null + receiver: GET_VAR ': .Delegated declared in .Delegated.foo' type=.Delegated 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 .IFoo + $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 .IFoo + $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 .IFoo + $this: VALUE_PARAMETER name: type:kotlin.Any + 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 ' + CALL 'public open fun foo (): kotlin.String declared in .Delegated' type=kotlin.String origin=null + $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Delegated' type=.Delegated origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt new file mode 100644 index 00000000000..6cd10d8e3f9 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: JVM + +// MODULE: lib +// FILE: A.java +public class A { + public String foo() { return null; } +} + +// MODULE: main(lib) +// FILE: nullCheckOnInterfaceDelegation.kt +interface IFoo { + fun foo(): String +} + +class Derived : A(), IFoo { + override fun foo() = super.foo() +} + +class Delegated : IFoo by Derived() + +fun testReturnValue(): String = + Delegated().foo() diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt new file mode 100644 index 00000000000..01d0b451694 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt.txt @@ -0,0 +1,40 @@ +// MODULE: lib +// MODULE: main +// FILE: nullCheckOnInterfaceDelegation.kt + +interface IFoo { + abstract fun foo(): String + +} + +class Derived : A, IFoo { + constructor() /* primary */ { + super/*A*/() + /* () */ + + } + + override fun foo(): @FlexibleNullability String? { + return super.foo() + } + +} + +class Delegated : IFoo { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Derived = Derived() + override fun foo(): String { + return .#$$delegate_0.foo() /*!! String */ + } + +} + +fun testReturnValue(): String { + return Delegated().foo() +} + diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.ir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.ir.txt new file mode 100644 index 00000000000..4c8e988b924 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.ir.txt @@ -0,0 +1,17 @@ +FILE fqName: fileName:/stringVsAny.kt + FUN name:useAny visibility:public modality:FINAL <> (fn:kotlin.Function0) returnType:kotlin.Any + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useAny (fn: kotlin.Function0): kotlin.Any declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Any origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0 declared in .useAny' type=kotlin.Function0 origin=VARIABLE_AS_FUNCTION + FUN name:testNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useAny (fn: kotlin.Function0): kotlin.Any declared in ' type=kotlin.Any origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + 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 .testNullCheck' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt new file mode 100644 index 00000000000..5a5c09e2407 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt @@ -0,0 +1,22 @@ +// TARGET_BACKEND: JVM +// FIR_IDENTICAL +// FILE: stringVsAny.kt +fun useAny(fn: () -> Any) = fn() + +fun testNullCheck() { + useAny { J.string() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt new file mode 100644 index 00000000000..ddc74e513bc --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt.txt @@ -0,0 +1,11 @@ +fun useAny(fn: Function0): Any { + return fn.invoke() +} + +fun testNullCheck() { + useAny(fn = local fun (): Any { + return string() /*!! String */ + } +) /*~> Unit */ +} + diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.ir.txt deleted file mode 100644 index 5f318e3557c..00000000000 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.ir.txt +++ /dev/null @@ -1,22 +0,0 @@ -FILE fqName: fileName:/stringVsTConstrained.kt - FUN name:useTConstrained visibility:public modality:FINAL (xs:kotlin.Array.useTConstrained>, fn:kotlin.Function0.useTConstrained>) returnType:T of .useTConstrained - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - VALUE_PARAMETER name:xs index:0 type:kotlin.Array.useTConstrained> - VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTConstrained> - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' - CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTConstrained origin=INVOKE - $this: GET_VAR 'fn: kotlin.Function0.useTConstrained> declared in .useTConstrained' type=kotlin.Function0.useTConstrained> origin=VARIABLE_AS_FUNCTION - FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit - VALUE_PARAMETER name:xs index:0 type:kotlin.Array - BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' type=kotlin.String origin=null - : kotlin.String - xs: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null - fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA - FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' - TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String - CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.kt.txt deleted file mode 100644 index 7686dc8a4bc..00000000000 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.kt.txt +++ /dev/null @@ -1,10 +0,0 @@ -fun useTConstrained(xs: Array, fn: Function0): T { - return fn.invoke() -} - -fun testWithNullCheck(xs: Array) { - useTConstrained(xs = xs, fn = local fun (): String { - return string() /*!! @FlexibleNullability String */ - } -) /*~> Unit */ -} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt index be06dbc8c25..b9573300c49 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // TARGET_BACKEND: JVM // FILE: stringVsTConstrained.kt fun useTConstrained(xs: Array, fn: () -> T) = fn() diff --git a/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.ir.txt deleted file mode 100644 index bd555558530..00000000000 --- a/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.ir.txt +++ /dev/null @@ -1,39 +0,0 @@ -FILE fqName: fileName:/nullabilityAssertionOnExtensionReceiver.kt - FUN name:extension visibility:public modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Unit - $receiver: VALUE_PARAMETER name: type:kotlin.String - BLOCK_BODY - CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C - CONSTRUCTOR visibility:public <> () returnType:.C [primary] - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:memberExtension visibility:public modality:FINAL <> ($this:.C, $receiver:kotlin.String) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.C - $receiver: VALUE_PARAMETER name: type:kotlin.String - BLOCK_BODY - 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 - 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: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String - CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] 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: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String - CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.kt.txt deleted file mode 100644 index be54d5cb795..00000000000 --- a/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.fir.kt.txt +++ /dev/null @@ -1,22 +0,0 @@ -fun String.extension() { -} - -class C { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun String.memberExtension() { - } - -} - -fun testExt() { - s() /*!! @FlexibleNullability String */.extension() -} - -fun C.testMemberExt() { - (, s() /*!! @FlexibleNullability String */).memberExtension() -} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.kt b/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.kt index e1327ca705c..e159f20676d 100644 --- a/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.kt +++ b/compiler/testData/ir/irText/types/nullChecks/nullabilityAssertionOnExtensionReceiver.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // TARGET_BACKEND: JVM // FILE: nullabilityAssertionOnExtensionReceiver.kt diff --git a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.ir.txt index 59e707f4164..c78d6eaa6b4 100644 --- a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.ir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.ir.txt @@ -12,10 +12,10 @@ FILE fqName: fileName:/typeParameterWithMixedNullableAndNotNullableBounds. TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun f (x: T of .f): kotlin.Int declared in ' type=kotlin.Int origin=null : @[FlexibleNullability] kotlin.String? - x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun f (x: T of .f): kotlin.Int declared in ' type=kotlin.Int origin=null : @[FlexibleNullability] kotlin.String? - x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.kt.txt index 459eb3b27f9..289293570c0 100644 --- a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMixedNullableAndNotNullableBounds.fir.kt.txt @@ -3,6 +3,7 @@ fun f(x: T): Int where T : CharSequence?, T : Comparable { } fun test() { - f<@FlexibleNullability String?>(x = s() /*!! @FlexibleNullability String */) /*~> Unit */ - f<@FlexibleNullability String?>(x = #STRING /*!! @FlexibleNullability String */) /*~> Unit */ + f<@FlexibleNullability String?>(x = s() /*!! String */) /*~> Unit */ + f<@FlexibleNullability String?>(x = #STRING /*!! String */) /*~> Unit */ } + diff --git a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.ir.txt b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.ir.txt index 2817951d04a..b7ba4111a79 100644 --- a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.ir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.ir.txt @@ -12,10 +12,10 @@ FILE fqName: fileName:/typeParameterWithMultipleNotNullableBounds.kt TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun f (x: T of .f): kotlin.Int declared in ' type=kotlin.Int origin=null : @[FlexibleNullability] kotlin.String? - x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun f (x: T of .f): kotlin.Int declared in ' type=kotlin.Int origin=null : @[FlexibleNullability] kotlin.String? - x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY diff --git a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.kt.txt b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.kt.txt index e5bb1f207e2..ec6e8101149 100644 --- a/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.kt.txt +++ b/compiler/testData/ir/irText/types/nullChecks/typeParameterWithMultipleNotNullableBounds.fir.kt.txt @@ -3,6 +3,7 @@ fun f(x: T): Int where T : CharSequence, T : Comparable { } fun test() { - f<@FlexibleNullability String?>(x = s() /*!! @FlexibleNullability String */) /*~> Unit */ - f<@FlexibleNullability String?>(x = #STRING /*!! @FlexibleNullability String */) /*~> Unit */ + f<@FlexibleNullability String?>(x = s() /*!! String */) /*~> Unit */ + f<@FlexibleNullability String?>(x = #STRING /*!! String */) /*~> Unit */ } + diff --git a/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.ir.txt b/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.ir.txt index 6235052494e..0cd33edcd68 100644 --- a/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.ir.txt +++ b/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.ir.txt @@ -21,7 +21,7 @@ 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 ' - TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:@[FlexibleNullability] T of .JCell? visibility:public' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY receiver: TYPE_OP type=.JCell origin=IMPLICIT_CAST typeOperand=.JCell GET_VAR 'a: kotlin.Any declared in .testGetField' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.kt.txt b/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.kt.txt index 754333fe89d..5cff33b63be 100644 --- a/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.kt.txt +++ b/compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.fir.kt.txt @@ -6,5 +6,6 @@ fun testSetField(a: Any, b: Any) { fun testGetField(a: Any): String { a as JCell /*~> Unit */ - return a /*as JCell */.#value /*!! @FlexibleNullability String */ + return a /*as JCell */.#value /*!! String */ } + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index a460762fc83..17e2ec26d5b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -2901,6 +2901,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.kt"); } + @Test + @TestMetadata("nullCheckOnInterfaceDelegation.kt") + public void testNullCheckOnInterfaceDelegation() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt"); + } + @Test @TestMetadata("nullabilityAssertionOnExtensionReceiver.kt") public void testNullabilityAssertionOnExtensionReceiver() throws Exception { @@ -2970,6 +2976,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt"); } + @Test + @TestMetadata("stringVsAny.kt") + public void testStringVsAny() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt"); + } + @Test @TestMetadata("stringVsT.kt") public void testStringVsT() throws Exception {