From d9dca067f6f228746c895a8f8ce0f13ddd91c89d Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 12 Jun 2019 20:43:02 +0300 Subject: [PATCH] [NI] Propagate non-null info on supertypes for capturing from bounds #KT-31941 Fixed --- .../fir/FirDiagnosticsSmokeTestGenerated.java | 5 + .../calls/components/SimpleArgumentsChecks.kt | 11 +- ...eNullailityOnSupertypesWhenCaptureTypes.kt | 23 ++ ...NullailityOnSupertypesWhenCaptureTypes.txt | 13 ++ .../diagnostics/notLinked/dfa/pos/12.kt | 214 ++++++++--------- .../diagnostics/notLinked/dfa/pos/13.kt | 220 +++++++++--------- .../checkers/DiagnosticsTestGenerated.java | 5 + .../DiagnosticsUsingJavacTestGenerated.java | 5 + 8 files changed, 274 insertions(+), 222 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt create mode 100644 compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.txt diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index eb282623294..72a4846c51a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -9860,6 +9860,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt"); } + @TestMetadata("propagateNullailityOnSupertypesWhenCaptureTypes.kt") + public void testPropagateNullailityOnSupertypesWhenCaptureTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt"); + } + @TestMetadata("starProjectionRegression.kt") public void testStarProjectionRegression() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/starProjectionRegression.kt"); diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/SimpleArgumentsChecks.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/SimpleArgumentsChecks.kt index cda98072f65..fb92148f478 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/SimpleArgumentsChecks.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/SimpleArgumentsChecks.kt @@ -25,14 +25,11 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.ArgumentConstraintPosi import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintPosition import org.jetbrains.kotlin.resolve.calls.inference.model.ReceiverConstraintPosition import org.jetbrains.kotlin.resolve.calls.model.* -import org.jetbrains.kotlin.types.NotNullTypeVariable -import org.jetbrains.kotlin.types.UnwrappedType +import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.captureFromExpression import org.jetbrains.kotlin.types.checker.hasSupertypeWithGivenTypeConstructor -import org.jetbrains.kotlin.types.lowerIfFlexible import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.supertypes -import org.jetbrains.kotlin.types.upperIfFlexible fun checkSimpleArgument( @@ -147,7 +144,11 @@ private fun captureFromTypeParameterUpperBoundIfNeeded(argumentType: UnwrappedTy it.unwrap().hasSupertypeWithGivenTypeConstructor(expectedTypeConstructor) } if (chosenSupertype != null) { - return captureFromExpression(chosenSupertype.unwrap()) ?: argumentType + val capturedType = captureFromExpression(chosenSupertype.unwrap()) + return if (capturedType != null && argumentType.isDefinitelyNotNullType) + capturedType.makeDefinitelyNotNullOrNotNull() + else + capturedType ?: argumentType } } diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt new file mode 100644 index 00000000000..0132370e669 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt @@ -0,0 +1,23 @@ +open class Inv(val value: String) + +fun ?, F: Inv?, G : Inv<*>> test1(t: T, f: F, g: G?) { + if (t != null && f != null && g != null) { + t.value + f.value + g.value + } +} + +// Actually, this behavior is very questional as capturing shouldn't be performed deeper than for 1 level +// But we preserve behavior of old inference here for now +fun ?> test2(t: T) { + if (t != null) { + t.value + } +} + +fun ?, K : Inv<*>?> test3(t: T) { + if (t != null) { + t.value + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.txt new file mode 100644 index 00000000000..bf0bde999d7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.txt @@ -0,0 +1,13 @@ +package + +public fun ?, /*1*/ F : Inv?, /*2*/ G : Inv<*>> test1(/*0*/ t: T, /*1*/ f: F, /*2*/ g: G?): kotlin.Unit +public fun ?> test2(/*0*/ t: T): kotlin.Unit +public fun ?, /*1*/ K : Inv<*>?> test3(/*0*/ t: T): kotlin.Unit + +public open class Inv { + public constructor Inv(/*0*/ value: kotlin.String) + public final val value: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.kt index 6a0febc9e6c..fc0372f357b 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/12.kt @@ -667,10 +667,10 @@ fun ?> T.case_14() { this.funAny() this.funNullableT() this.funNullableAny() - this.get() + this.get() equals(this) - get() + get() apply { this equals(null) @@ -682,7 +682,7 @@ fun ?> T.case_14() { funAny() funNullableT() funNullableAny() - get() + get() this.equals(null) this.propT this.propAny @@ -692,11 +692,11 @@ fun ?> T.case_14() { this.funAny() this.funNullableT() this.funNullableAny() - this.get() + this.get() } also { it - it.get() + it.get() it.equals(null) it.propT it.propAny @@ -727,10 +727,10 @@ fun ?> T.case_15() { this.funAny() this.funNullableT() this.funNullableAny() - this.itest1() + this.itest1() equals(this) - itest1() + itest1() apply { this equals(null) @@ -742,7 +742,7 @@ fun ?> T.case_15() { funAny() funNullableT() funNullableAny() - itest1() + itest1() this.equals(null) this.propT this.propAny @@ -752,11 +752,11 @@ fun ?> T.case_15() { this.funAny() this.funNullableT() this.funNullableAny() - this.itest1() + this.itest1() } also { it - it.itest1() + it.itest1() it.equals(null) it.propT it.propAny @@ -787,10 +787,10 @@ fun ?> T.case_16() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() equals(this) - ip1test1() + ip1test1() apply { this equals(null) @@ -802,7 +802,7 @@ fun ?> T.case_16() { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -812,11 +812,11 @@ fun ?> T.case_16() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -847,10 +847,10 @@ fun ?> T.case_17() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() equals(this) - ip1test1() + ip1test1() apply { this equals(null) @@ -862,7 +862,7 @@ fun ?> T.case_17() { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -872,11 +872,11 @@ fun ?> T.case_17() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -909,7 +909,7 @@ fun ?> T.case_18() { y.funAny() y.funNullableT() y.funNullableAny() - y.ip1test1() + y.ip1test1() equals(y) ip1test1() @@ -961,10 +961,10 @@ fun ?> T.case_19() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() equals(this) - ip1test1() + ip1test1() apply { this equals(null) @@ -976,7 +976,7 @@ fun ?> T.case_19() { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -986,11 +986,11 @@ fun ?> T.case_19() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -1021,12 +1021,12 @@ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWit this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() - this.ip1test2() + this.ip1test1() + this.ip1test2() equals(this) - ip1test1() - ip1test2() + ip1test1() + ip1test2() apply { this equals(null) @@ -1038,8 +1038,8 @@ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWit funAny() funNullableT() funNullableAny() - ip1test1() - ip1test2() + ip1test1() + ip1test2() this.equals(null) this.propT this.propAny @@ -1049,8 +1049,8 @@ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWit this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() - this.ip1test2() + this.ip1test1() + this.ip1test2() } also { it @@ -1063,8 +1063,8 @@ fun T.case_20() where T: InterfaceWithTypeParameter1?, T: InterfaceWit it.funAny() it.funNullableT() it.funNullableAny() - it.ip1test1() - it.ip1test2() + it.ip1test1() + it.ip1test2() } } } @@ -1086,13 +1086,13 @@ fun T.case_21() where T: InterfaceWithTypeParameter1?, T: InterfaceWit this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() - this.ip1test2() + this.ip1test1() + this.ip1test2() this.ip1test3() equals(this) - ip1test1() - ip1test2() + ip1test1() + ip1test2() ip1test3() apply { this @@ -1105,8 +1105,8 @@ fun T.case_21() where T: InterfaceWithTypeParameter1?, T: InterfaceWit funAny() funNullableT() funNullableAny() - ip1test1() - ip1test2() + ip1test1() + ip1test2() ip1test3() this.equals(null) this.propT @@ -1117,8 +1117,8 @@ fun T.case_21() where T: InterfaceWithTypeParameter1?, T: InterfaceWit this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() - this.ip1test2() + this.ip1test1() + this.ip1test2() this.ip1test3() } also { @@ -1132,8 +1132,8 @@ fun T.case_21() where T: InterfaceWithTypeParameter1?, T: InterfaceWit it.funAny() it.funNullableT() it.funNullableAny() - it.ip1test1() - it.ip1test2() + it.ip1test1() + it.ip1test2() it.ip1test3() } } @@ -2864,11 +2864,11 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -2881,7 +2881,7 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -2892,7 +2892,7 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -2906,19 +2906,19 @@ fun T?.case_47() where T : Inv, T: Comparable<*>?, T: InterfaceWithTypePa it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } - this.compareTo(return) - compareTo(return) + this.compareTo(return) + compareTo(return) apply { - compareTo(return) - this.compareTo(return) + compareTo(return) + this.compareTo(return) } also { - it.compareTo(return) + it.compareTo(return) } } } @@ -2941,11 +2941,11 @@ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -2958,7 +2958,7 @@ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -2969,7 +2969,7 @@ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -2983,7 +2983,7 @@ fun T?.case_48() where T : Inv, T: InterfaceWithTypeParameter1? it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } } } @@ -3006,11 +3006,11 @@ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -3023,7 +3023,7 @@ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3034,7 +3034,7 @@ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -3048,7 +3048,7 @@ fun T?.case_49() where T : Inv, T: InterfaceWithTypeParameter1? it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } } } @@ -3071,11 +3071,11 @@ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1 this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -3088,7 +3088,7 @@ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1 funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3099,7 +3099,7 @@ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1 this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -3113,7 +3113,7 @@ fun T?.case_50() where T : Inv, T: InterfaceWithTypeParameter1 it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } } } @@ -3136,11 +3136,11 @@ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -3153,7 +3153,7 @@ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3164,7 +3164,7 @@ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -3178,7 +3178,7 @@ fun T?.case_51() where T : Inv, T: InterfaceWithTypeParameter1? { it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } } } @@ -3262,11 +3262,11 @@ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -3279,7 +3279,7 @@ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3290,7 +3290,7 @@ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -3304,7 +3304,7 @@ fun T?.case_53() where T : Inv, T: InterfaceWithTypeParameter1<*>? { it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } } } @@ -3327,11 +3327,11 @@ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() equals(this) get() - ip1test1() + ip1test1() apply { this equals(null) @@ -3344,7 +3344,7 @@ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { funNullableT() funNullableAny() get() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3355,7 +3355,7 @@ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { this.funNullableT() this.funNullableAny() this.get() - this.ip1test1() + this.ip1test1() } also { it @@ -3369,7 +3369,7 @@ fun T?.case_54() where T : Inv<*>, T: InterfaceWithTypeParameter1? { it.funNullableT() it.funNullableAny() it.get() - it.ip1test1() + it.ip1test1() } } } @@ -3650,14 +3650,14 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1this.funAny() this.funNullableT() this.funNullableAny() - this.itest1() - this.itest2() - this.itest3() + this.itest1() + this.itest2() + this.itest3() equals(this) - itest1() - itest2() - itest3() + itest1() + itest2() + itest3() apply { this equals(null) @@ -3669,9 +3669,9 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1itest1() - itest2() - itest3() + itest1() + itest2() + itest3() this.equals(null) this.propT this.propAny @@ -3681,9 +3681,9 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1this.funAny() this.funNullableT() this.funNullableAny() - this.itest1() - this.itest2() - this.itest3() + this.itest1() + this.itest2() + this.itest3() } also { it @@ -3696,9 +3696,9 @@ fun T.case_59() where T: InterfaceWithFiveTypeParameters1it.funAny() it.funNullableT() it.funNullableAny() - it.itest1() - it.itest2() - it.itest3() + it.itest1() + it.itest2() + it.itest3() } } } @@ -3720,10 +3720,10 @@ fun ?> T.case_60() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() equals(this) - ip1test1() + ip1test1() apply { this equals(null) @@ -3735,7 +3735,7 @@ fun ?> T.case_60() { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3745,7 +3745,7 @@ fun ?> T.case_60() { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } also { it @@ -3758,7 +3758,7 @@ fun ?> T.case_60() { it.funAny() it.funNullableT() it.funNullableAny() - it.ip1test1() + it.ip1test1() } } } @@ -3839,7 +3839,7 @@ fun Nothing.case_63() { also { it it.hashCode() - } + } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.kt index 184a170fe40..ef32d7090b1 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/13.kt @@ -783,7 +783,7 @@ fun ?> case_14(x: T) { x.funAny() x.funNullableT() x.funNullableAny() - x.get() + x.get() x.equals(null) @@ -802,7 +802,7 @@ fun ?> case_14(x: T) { x.funNullableT() x.funNullableAny() - x.get() + x.get() x.apply { this equals(null) @@ -814,7 +814,7 @@ fun ?> case_14(x: T) { funAny() funNullableT() funNullableAny() - get() + get() this.equals(null) this.propT this.propAny @@ -824,11 +824,11 @@ fun ?> case_14(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.get() + this.get() } x.also { it - it.get() + it.get() it.equals(null) it.propT it.propAny @@ -859,7 +859,7 @@ fun ?> case_15(x: T) { x.funAny() x.funNullableT() x.funNullableAny() - x.itest() + x.itest() x.equals(null) @@ -878,7 +878,7 @@ fun ?> case_15(x: T) { x.funNullableT() x.funNullableAny() - x.itest() + x.itest() x.apply { this equals(null) @@ -890,7 +890,7 @@ fun ?> case_15(x: T) { funAny() funNullableT() funNullableAny() - itest() + itest() this.equals(null) this.propT this.propAny @@ -900,11 +900,11 @@ fun ?> case_15(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.itest() + this.itest() } x.also { it - it.itest() + it.itest() it.equals(null) it.propT it.propAny @@ -935,7 +935,7 @@ fun ?> case_16(x: T) { x.funAny() x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -954,7 +954,7 @@ fun ?> case_16(x: T) { x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -966,7 +966,7 @@ fun ?> case_16(x: T) { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -976,11 +976,11 @@ fun ?> case_16(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } x.also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -1011,7 +1011,7 @@ fun ?> case_17(x: T) { x.funAny() x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -1030,7 +1030,7 @@ fun ?> case_17(x: T) { x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -1042,7 +1042,7 @@ fun ?> case_17(x: T) { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -1052,11 +1052,11 @@ fun ?> case_17(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } x.also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -1089,7 +1089,7 @@ fun ?> case_18(x: T) { y.funAny() y.funNullableT() y.funNullableAny() - y.ip1test1() + y.ip1test1() x.equals(null) @@ -1108,7 +1108,7 @@ fun ?> case_18(x: T) { x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -1120,7 +1120,7 @@ fun ?> case_18(x: T) { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -1130,11 +1130,11 @@ fun ?> case_18(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } x.also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -1165,7 +1165,7 @@ fun ?> case_19(x: T) { x.funAny() x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -1184,7 +1184,7 @@ fun ?> case_19(x: T) { x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -1196,7 +1196,7 @@ fun ?> case_19(x: T) { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -1206,11 +1206,11 @@ fun ?> case_19(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } x.also { it - it.ip1test1() + it.ip1test1() it.equals(null) it.propT it.propAny @@ -1241,8 +1241,8 @@ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW x.funAny() x.funNullableT() x.funNullableAny() - x.ip1test1() - x.ip1test2() + x.ip1test1() + x.ip1test2() x.equals(null) @@ -1261,8 +1261,8 @@ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW x.funNullableT() x.funNullableAny() - x.ip1test1() - x.ip1test2() + x.ip1test1() + x.ip1test2() x.apply { this equals(null) @@ -1274,8 +1274,8 @@ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW funAny() funNullableT() funNullableAny() - ip1test1() - ip1test2() + ip1test1() + ip1test2() this.equals(null) this.propT this.propAny @@ -1285,8 +1285,8 @@ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() - this.ip1test2() + this.ip1test1() + this.ip1test2() } x.also { it @@ -1299,8 +1299,8 @@ fun case_20(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW it.funAny() it.funNullableT() it.funNullableAny() - it.ip1test1() - it.ip1test2() + it.ip1test1() + it.ip1test2() } } } @@ -1322,8 +1322,8 @@ fun case_21(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW x.funAny() x.funNullableT() x.funNullableAny() - x.ip1test1() - x.ip1test2() + x.ip1test1() + x.ip1test2() x.ip1test3() x.equals(null) @@ -1343,8 +1343,8 @@ fun case_21(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW x.funNullableT() x.funNullableAny() - x.ip1test1() - x.ip1test2() + x.ip1test1() + x.ip1test2() x.ip1test3() x.apply { this @@ -1357,8 +1357,8 @@ fun case_21(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW funAny() funNullableT() funNullableAny() - ip1test1() - ip1test2() + ip1test1() + ip1test2() ip1test3() this.equals(null) this.propT @@ -1369,8 +1369,8 @@ fun case_21(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() - this.ip1test2() + this.ip1test1() + this.ip1test2() this.ip1test3() } x.also { @@ -1384,8 +1384,8 @@ fun case_21(x: T) where T: InterfaceWithTypeParameter1?, T: InterfaceW it.funAny() it.funNullableT() it.funNullableAny() - it.ip1test1() - it.ip1test2() + it.ip1test1() + it.ip1test2() it.ip1test3() } } @@ -3212,7 +3212,7 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3232,7 +3232,7 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3245,7 +3245,7 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType funNullableT() funNullableAny() test() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3256,7 +3256,7 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3270,19 +3270,19 @@ fun case_47(x: T?) where T : Inv, T: Comparable<*>?, T: InterfaceWithType it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } - x.compareTo(return) - x.compareTo(return) + x.compareTo(return) + x.compareTo(return) x.apply { - compareTo(return) - this.compareTo(return) + compareTo(return) + this.compareTo(return) } x.also { - it.compareTo(return) + it.compareTo(return) } } } @@ -3305,7 +3305,7 @@ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3325,7 +3325,7 @@ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3338,7 +3338,7 @@ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3349,7 +3349,7 @@ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3363,7 +3363,7 @@ fun case_48(x: T?) where T : Inv, T: InterfaceWithTypeParameter1it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } } } @@ -3386,7 +3386,7 @@ fun case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3406,7 +3406,7 @@ fun case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3419,7 +3419,7 @@ fun case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 funNullableT() funNullableAny() test() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3430,7 +3430,7 @@ fun case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3444,7 +3444,7 @@ fun case_49(x: T?) where T : Inv, T: InterfaceWithTypeParameter1 it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } } } @@ -3467,7 +3467,7 @@ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3487,7 +3487,7 @@ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3500,7 +3500,7 @@ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3511,7 +3511,7 @@ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3525,7 +3525,7 @@ fun case_50(x: T?) where T : Inv, T: InterfaceWithTypeParameter1it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } } } @@ -3548,7 +3548,7 @@ fun case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3568,7 +3568,7 @@ fun case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3581,7 +3581,7 @@ fun case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? funNullableT() funNullableAny() test() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3592,7 +3592,7 @@ fun case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3606,7 +3606,7 @@ fun case_51(x: T?) where T : Inv, T: InterfaceWithTypeParameter1? it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } } } @@ -3706,7 +3706,7 @@ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3726,7 +3726,7 @@ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3739,7 +3739,7 @@ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { funNullableT() funNullableAny() test() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3750,7 +3750,7 @@ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3764,7 +3764,7 @@ fun case_53(x: T?) where T : Inv, T: InterfaceWithTypeParameter1<*>? { it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } } } @@ -3787,7 +3787,7 @@ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? x.funNullableT() x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -3807,7 +3807,7 @@ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? x.funNullableAny() x.test() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -3820,7 +3820,7 @@ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? funNullableT() funNullableAny() test() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -3831,7 +3831,7 @@ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? this.funNullableT() this.funNullableAny() this.test() - this.ip1test1() + this.ip1test1() } x.also { it @@ -3845,7 +3845,7 @@ fun case_54(x: T?) where T : Inv<*>, T: InterfaceWithTypeParameter1? it.funNullableT() it.funNullableAny() it.test() - it.ip1test1() + it.ip1test1() } } } @@ -4174,9 +4174,9 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1x.funAny() x.funNullableT() x.funNullableAny() - x.itest1() - x.itest2() - x.itest3() + x.itest1() + x.itest2() + x.itest3() x.equals(null) @@ -4195,9 +4195,9 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1.itest1() - x.itest2() - x.itest3() + x.itest1() + x.itest2() + x.itest3() x.apply { this equals(null) @@ -4209,9 +4209,9 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1itest1() - itest2() - itest3() + itest1() + itest2() + itest3() this.equals(null) this.propT this.propAny @@ -4221,9 +4221,9 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1this.funAny() this.funNullableT() this.funNullableAny() - this.itest1() - this.itest2() - this.itest3() + this.itest1() + this.itest2() + this.itest3() } x.also { it @@ -4236,9 +4236,9 @@ fun case_59(x: T) where T: InterfaceWithFiveTypeParameters1it.funAny() it.funNullableT() it.funNullableAny() - it.itest1() - it.itest2() - it.itest3() + it.itest1() + it.itest2() + it.itest3() } } } @@ -4260,7 +4260,7 @@ fun ?> case_60(x: T) { x.funAny() x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.equals(null) @@ -4279,7 +4279,7 @@ fun ?> case_60(x: T) { x.funNullableT() x.funNullableAny() - x.ip1test1() + x.ip1test1() x.apply { this equals(null) @@ -4291,7 +4291,7 @@ fun ?> case_60(x: T) { funAny() funNullableT() funNullableAny() - ip1test1() + ip1test1() this.equals(null) this.propT this.propAny @@ -4301,7 +4301,7 @@ fun ?> case_60(x: T) { this.funAny() this.funNullableT() this.funNullableAny() - this.ip1test1() + this.ip1test1() } x.also { it @@ -4314,7 +4314,7 @@ fun ?> case_60(x: T) { it.funAny() it.funNullableT() it.funNullableAny() - it.ip1test1() + it.ip1test1() } } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 1c88b376c97..bf1938640f4 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -9867,6 +9867,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt"); } + @TestMetadata("propagateNullailityOnSupertypesWhenCaptureTypes.kt") + public void testPropagateNullailityOnSupertypesWhenCaptureTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt"); + } + @TestMetadata("starProjectionRegression.kt") public void testStarProjectionRegression() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/starProjectionRegression.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 3d4781f19d6..4039be19101 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -9862,6 +9862,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/overApproximationForOutCaptured.kt"); } + @TestMetadata("propagateNullailityOnSupertypesWhenCaptureTypes.kt") + public void testPropagateNullailityOnSupertypesWhenCaptureTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/propagateNullailityOnSupertypesWhenCaptureTypes.kt"); + } + @TestMetadata("starProjectionRegression.kt") public void testStarProjectionRegression() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/starProjectionRegression.kt");