diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 425de6aa440..930fc1b48ec 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -31000,6 +31000,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt"); } + @Test + @TestMetadata("implicitNothingInDelegate.kt") + public void testImplicitNothingInDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt"); + } + @Test @TestMetadata("InaccessibleInternalClass.kt") public void testInaccessibleInternalClass() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 7ba52d05a65..f19a4e5d0d5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -15268,6 +15268,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt"); } + @Test + @TestMetadata("implicitNothingInDelegate.kt") + public void testImplicitNothingInDelegate() throws Exception { + runTest("compiler/testData/codegen/box/fir/implicitNothingInDelegate.kt"); + } + @Test @TestMetadata("incorrectBytecodeWithEnhancedNullability.kt") public void testIncorrectBytecodeWithEnhancedNullability() throws Exception { diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt index b6e7697e17c..7f0dab2369f 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/inference/components/AbstractTypeCheckerContextForConstraintSystem.kt @@ -91,9 +91,6 @@ abstract class AbstractTypeCheckerContextForConstraintSystem(override val typeSy val typeMarker = type.asSimpleType()?.asCapturedType() ?: return null val projection = typeMarker.typeConstructorProjection() - if (projection.isStarProjection()) return null - - return when (projection.getVariance()) { TypeVariance.IN -> if (!out) typeMarker.lowerType() ?: projection.getType() else null TypeVariance.OUT -> if (out) projection.getType() else null diff --git a/compiler/testData/codegen/box/fir/implicitNothingInDelegate.kt b/compiler/testData/codegen/box/fir/implicitNothingInDelegate.kt new file mode 100644 index 00000000000..b9d81797dec --- /dev/null +++ b/compiler/testData/codegen/box/fir/implicitNothingInDelegate.kt @@ -0,0 +1,11 @@ +// TARGET_BACKEND: JVM_IR +// WITH_RUNTIME + +// Note: this test passes in FIR but fails in FE 1.0 + IR +fun box(): String { + val m1: Map = mapOf("foo" to "O") + val m2: Map = mapOf("baz" to "K") + val foo: String by m1 + val baz: String by m2 + return foo + baz +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt new file mode 100644 index 00000000000..6f27fd99014 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.fir.txt @@ -0,0 +1,18 @@ +FILE: implicitNothingInDelegate.kt + @R|kotlin/Suppress|(vararg(String(INVISIBLE_REFERENCE))) public final operator fun R|kotlin/collections/Map|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V1| { + ^getValue Null(null)!! + } + public final val m2: R|kotlin/collections/Map| = R|kotlin/collections/mapOf|(String(baz).R|kotlin/to|(String(bat))) + public get(): R|kotlin/collections/Map| + public final val bar: R|kotlin/String| + public get(): R|kotlin/String| { + ^ R|/m2|.R|/getValue|(Null(null), ::R|/bar|) + } + public final fun foo(): R|kotlin/Unit| { + lval m1: R|kotlin/collections/Map| = R|kotlin/collections/mapOf|(String(foo).R|kotlin/to|(String(bar))) + lval foo: R|kotlin/String|by R|/m1| + lval baz: R|kotlin/String|by R|/m2| + R|kotlin/io/println|(R|/foo|) + R|kotlin/io/println|(R|/baz|) + R|kotlin/io/println|(R|/bar|) + } diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt new file mode 100644 index 00000000000..792c2c46961 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt @@ -0,0 +1,20 @@ +// FIR_IDENTICAL +// FIR_DUMP +// WITH_REFLECT + +import kotlin.reflect.KProperty + +@Suppress("INVISIBLE_REFERENCE") +public operator fun Map.getValue(thisRef: Any?, property: KProperty<*>): V1 = null!! + +val m2: Map = mapOf("baz" to "bat") +val bar: String get() = m2.getValue(null, ::bar) + +fun foo() { + val m1: Map = mapOf("foo" to "bar") + val foo: String by m1 + val baz: String by m2 + println(foo) // bar + println(baz) // kotlin.KotlinNothingValueException + println(bar) +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.txt b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.txt new file mode 100644 index 00000000000..cc3247a96f3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.txt @@ -0,0 +1,7 @@ +package + +public val bar: kotlin.String +public val m2: kotlin.collections.Map +public fun foo(): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_REFERENCE"}) public operator fun kotlin.collections.Map.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): V1 + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 6f0000a8e8a..98bcca49d9c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -31096,6 +31096,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt"); } + @Test + @TestMetadata("implicitNothingInDelegate.kt") + public void testImplicitNothingInDelegate() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt"); + } + @Test @TestMetadata("InaccessibleInternalClass.kt") public void testInaccessibleInternalClass() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 1c006575301..9e6cb9f2afe 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -15268,6 +15268,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt"); } + @Test + @TestMetadata("implicitNothingInDelegate.kt") + public void testImplicitNothingInDelegate() throws Exception { + runTest("compiler/testData/codegen/box/fir/implicitNothingInDelegate.kt"); + } + @Test @TestMetadata("incorrectBytecodeWithEnhancedNullability.kt") public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {