Propagate input type position across incorporation properly

^KT-45719 Fixed
This commit is contained in:
Victor Petukhov
2021-03-26 17:01:26 +03:00
parent d06031ece3
commit 7f2c5cde55
6 changed files with 48 additions and 1 deletions
@@ -12191,6 +12191,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt");
}
@Test
@TestMetadata("onlyInputTypesWithMultilevelIncorporation.kt")
public void testOnlyInputTypesWithMultilevelIncorporation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt");
}
@Test
@TestMetadata("opposite.kt")
public void testOpposite() throws Exception {
@@ -219,7 +219,8 @@ class ConstraintIncorporator(
val kind = if (isSubtype) ConstraintKind.LOWER else ConstraintKind.UPPER
val inputTypePosition = baseConstraint.position.from as? OnlyInputTypeConstraintPosition
val inputTypePosition =
baseConstraint.position.from as? OnlyInputTypeConstraintPosition ?: baseConstraint.inputTypePositionBeforeIncorporation
val isNewConstraintUsefulForNullability = isUsefulForNullabilityConstraint && newConstraint.isNullableNothing()
val isOtherConstraintUsefulForNullability = otherConstraint.isNullabilityConstraint && otherConstraint.type.isNullableNothing()
@@ -0,0 +1,15 @@
// WITH_RUNTIME
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
import kotlin.internal.OnlyInputTypes
fun <<!HIDDEN!>@OnlyInputTypes<!> T> assertEquals(expected: T, actual: T, message: String? = null) {}
fun main() {
assertEquals(
mapOf(1 to "1", 2 to "2", 3 to "3"),
intArrayOf(1, 2, 3).associateWith { it.toString() }
)
}
@@ -0,0 +1,15 @@
// WITH_RUNTIME
// !DIAGNOSTICS: -UNUSED_PARAMETER
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
import kotlin.internal.OnlyInputTypes
fun <@OnlyInputTypes T> assertEquals(expected: T, actual: T, message: String? = null) {}
fun main() {
assertEquals(
mapOf(1 to "1", 2 to "2", 3 to "3"),
intArrayOf(1, 2, 3).associateWith { it.toString() }
)
}
@@ -0,0 +1,4 @@
package
public fun </*0*/ @kotlin.internal.OnlyInputTypes T> assertEquals(/*0*/ expected: T, /*1*/ actual: T, /*2*/ message: kotlin.String? = ...): kotlin.Unit
public fun main(): kotlin.Unit
@@ -12197,6 +12197,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt");
}
@Test
@TestMetadata("onlyInputTypesWithMultilevelIncorporation.kt")
public void testOnlyInputTypesWithMultilevelIncorporation() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/onlyInputTypesWithMultilevelIncorporation.kt");
}
@Test
@TestMetadata("opposite.kt")
public void testOpposite() throws Exception {