Inference: handle Exact constraints with captured types properly
#KT-41818 Fixed
This commit is contained in:
+6
@@ -31000,6 +31000,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("implicitNothingInDelegate.kt")
|
||||||
|
public void testImplicitNothingInDelegate() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("InaccessibleInternalClass.kt")
|
@TestMetadata("InaccessibleInternalClass.kt")
|
||||||
public void testInaccessibleInternalClass() throws Exception {
|
public void testInaccessibleInternalClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -15268,6 +15268,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt");
|
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
|
@Test
|
||||||
@TestMetadata("incorrectBytecodeWithEnhancedNullability.kt")
|
@TestMetadata("incorrectBytecodeWithEnhancedNullability.kt")
|
||||||
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
||||||
|
|||||||
-3
@@ -91,9 +91,6 @@ abstract class AbstractTypeCheckerContextForConstraintSystem(override val typeSy
|
|||||||
val typeMarker = type.asSimpleType()?.asCapturedType() ?: return null
|
val typeMarker = type.asSimpleType()?.asCapturedType() ?: return null
|
||||||
|
|
||||||
val projection = typeMarker.typeConstructorProjection()
|
val projection = typeMarker.typeConstructorProjection()
|
||||||
if (projection.isStarProjection()) return null
|
|
||||||
|
|
||||||
|
|
||||||
return when (projection.getVariance()) {
|
return when (projection.getVariance()) {
|
||||||
TypeVariance.IN -> if (!out) typeMarker.lowerType() ?: projection.getType() else null
|
TypeVariance.IN -> if (!out) typeMarker.lowerType() ?: projection.getType() else null
|
||||||
TypeVariance.OUT -> if (out) projection.getType() else null
|
TypeVariance.OUT -> if (out) projection.getType() else null
|
||||||
|
|||||||
@@ -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<String, Any> = mapOf("foo" to "O")
|
||||||
|
val m2: Map<String, *> = mapOf("baz" to "K")
|
||||||
|
val foo: String by m1
|
||||||
|
val baz: String by m2
|
||||||
|
return foo + baz
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
FILE: implicitNothingInDelegate.kt
|
||||||
|
@R|kotlin/Suppress|(vararg(String(INVISIBLE_REFERENCE))) public final operator fun <V, V1 : R|V|> R|kotlin/collections/Map<in kotlin/String, @Exact V>|.getValue(thisRef: R|kotlin/Any?|, property: R|kotlin/reflect/KProperty<*>|): R|V1| {
|
||||||
|
^getValue Null(null)!!
|
||||||
|
}
|
||||||
|
public final val m2: R|kotlin/collections/Map<kotlin/String, *>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/String|>(String(baz).R|kotlin/to|<R|kotlin/String|, R|kotlin/String|>(String(bat)))
|
||||||
|
public get(): R|kotlin/collections/Map<kotlin/String, *>|
|
||||||
|
public final val bar: R|kotlin/String|
|
||||||
|
public get(): R|kotlin/String| {
|
||||||
|
^ R|/m2|.R|/getValue|<R|kotlin/Any?|, R|kotlin/String|>(Null(null), ::R|/bar|)
|
||||||
|
}
|
||||||
|
public final fun foo(): R|kotlin/Unit| {
|
||||||
|
lval m1: R|kotlin/collections/Map<kotlin/String, kotlin/Any>| = R|kotlin/collections/mapOf|<R|kotlin/String|, R|kotlin/String|>(String(foo).R|kotlin/to|<R|kotlin/String|, R|kotlin/String|>(String(bar)))
|
||||||
|
lval foo: R|kotlin/String|by R|<local>/m1|
|
||||||
|
lval baz: R|kotlin/String|by R|/m2|
|
||||||
|
R|kotlin/io/println|(R|<local>/foo|)
|
||||||
|
R|kotlin/io/println|(R|<local>/baz|)
|
||||||
|
R|kotlin/io/println|(R|/bar|)
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// FIR_DUMP
|
||||||
|
// WITH_REFLECT
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
@Suppress("INVISIBLE_REFERENCE")
|
||||||
|
public operator fun <V, V1 : V> Map<in String, @kotlin.internal.Exact V>.getValue(thisRef: Any?, property: KProperty<*>): V1 = null!!
|
||||||
|
|
||||||
|
val m2: Map<String, *> = mapOf("baz" to "bat")
|
||||||
|
val bar: String get() = m2.getValue(null, ::bar)
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val m1: Map<String, Any> = mapOf("foo" to "bar")
|
||||||
|
val foo: String by m1
|
||||||
|
val baz: String by m2
|
||||||
|
println(foo) // bar
|
||||||
|
println(baz) // kotlin.KotlinNothingValueException
|
||||||
|
println(bar)
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val bar: kotlin.String
|
||||||
|
public val m2: kotlin.collections.Map<kotlin.String, *>
|
||||||
|
public fun foo(): kotlin.Unit
|
||||||
|
@kotlin.Suppress(names = {"INVISIBLE_REFERENCE"}) public operator fun </*0*/ V, /*1*/ V1 : V> kotlin.collections.Map<in kotlin.String, V>.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): V1
|
||||||
|
|
||||||
Generated
+6
@@ -31096,6 +31096,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/implicitCastToAny.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("implicitNothingInDelegate.kt")
|
||||||
|
public void testImplicitNothingInDelegate() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/implicitNothingInDelegate.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("InaccessibleInternalClass.kt")
|
@TestMetadata("InaccessibleInternalClass.kt")
|
||||||
public void testInaccessibleInternalClass() throws Exception {
|
public void testInaccessibleInternalClass() throws Exception {
|
||||||
|
|||||||
+6
@@ -15268,6 +15268,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/Fir2IrClassifierStorage.kt");
|
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
|
@Test
|
||||||
@TestMetadata("incorrectBytecodeWithEnhancedNullability.kt")
|
@TestMetadata("incorrectBytecodeWithEnhancedNullability.kt")
|
||||||
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
public void testIncorrectBytecodeWithEnhancedNullability() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user