NI: Fix property references overload ambiguity

^KT-35213 Fixed
This commit is contained in:
Denis Zharkov
2019-12-18 15:23:56 +03:00
parent ab79c3e0a0
commit dd56c3d918
6 changed files with 46 additions and 3 deletions
@@ -2410,6 +2410,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/callableReference/property/extensionPropertyOnNullable.kt");
}
@TestMetadata("extensionsSameName.kt")
public void testExtensionsSameName() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/extensionsSameName.kt");
}
@TestMetadata("genericClass.kt")
public void testGenericClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt");
@@ -191,8 +191,8 @@ private fun ConstraintSystemBuilder.addConstraintFromLHS(lhsResult: LHSResult.Ty
when (expectedTypeProjectionForLHS.projectionKind) {
Variance.INVARIANT -> addEqualityConstraint(lhsType, expectedTypeForLHS, constraintPosition)
Variance.IN_VARIANCE -> addSubtypeConstraint(expectedType, lhsType, constraintPosition)
Variance.OUT_VARIANCE -> addSubtypeConstraint(lhsType, expectedType, constraintPosition)
Variance.IN_VARIANCE -> addSubtypeConstraint(expectedTypeForLHS, lhsType, constraintPosition)
Variance.OUT_VARIANCE -> addSubtypeConstraint(lhsType, expectedTypeForLHS, constraintPosition)
}
}
@@ -207,4 +207,4 @@ private fun preprocessCollectionLiteralArgument(
internal inline fun <reified T : Any> Any.requireIs(): T {
require(this is T)
return this
}
}
@@ -0,0 +1,14 @@
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun check1(p: kotlin.reflect.KProperty1<*, *>) {}
fun check2(p: kotlin.reflect.KProperty1<in String, *>) {}
val CharSequence.x: Any get() = this
val BooleanArray.x: Any get() = this
fun box() {
check1(CharSequence::x) // error in NI, ok in OI
check2(CharSequence::x)
}
@@ -0,0 +1,14 @@
// SKIP_TXT
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun check1(p: kotlin.reflect.KProperty1<*, *>) {}
fun check2(p: kotlin.reflect.KProperty1<in String, *>) {}
val CharSequence.x: Any get() = this
val BooleanArray.x: Any get() = this
fun box() {
check1(CharSequence::x) // error in NI, ok in OI
check2(CharSequence::x)
}
@@ -2417,6 +2417,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/callableReference/property/extensionPropertyOnNullable.kt");
}
@TestMetadata("extensionsSameName.kt")
public void testExtensionsSameName() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/extensionsSameName.kt");
}
@TestMetadata("genericClass.kt")
public void testGenericClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt");
@@ -2412,6 +2412,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/callableReference/property/extensionPropertyOnNullable.kt");
}
@TestMetadata("extensionsSameName.kt")
public void testExtensionsSameName() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/extensionsSameName.kt");
}
@TestMetadata("genericClass.kt")
public void testGenericClass() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/property/genericClass.kt");