[FIR] Prioritize double over float in overload resolution

#KT-57194 Fixed
This commit is contained in:
Kirill Rakhman
2023-03-08 15:34:03 +01:00
committed by Space Team
parent 525317962c
commit fa432d7f0d
6 changed files with 45 additions and 4 deletions
@@ -23474,6 +23474,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
}
@Test
@TestMetadata("doubleWinsOverFloat.kt")
public void testDoubleWinsOverFloat() throws Exception {
runTest("compiler/testData/diagnostics/tests/overload/doubleWinsOverFloat.kt");
}
@Test
@TestMetadata("EmptyArgumentListInLambda.kt")
public void testEmptyArgumentListInLambda() throws Exception {
@@ -23474,6 +23474,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
}
@Test
@TestMetadata("doubleWinsOverFloat.kt")
public void testDoubleWinsOverFloat() throws Exception {
runTest("compiler/testData/diagnostics/tests/overload/doubleWinsOverFloat.kt");
}
@Test
@TestMetadata("EmptyArgumentListInLambda.kt")
public void testEmptyArgumentListInLambda() throws Exception {
@@ -23480,6 +23480,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
}
@Test
@TestMetadata("doubleWinsOverFloat.kt")
public void testDoubleWinsOverFloat() throws Exception {
runTest("compiler/testData/diagnostics/tests/overload/doubleWinsOverFloat.kt");
}
@Test
@TestMetadata("EmptyArgumentListInLambda.kt")
public void testEmptyArgumentListInLambda() throws Exception {
@@ -67,9 +67,6 @@ abstract class AbstractConeCallConflictResolver(
requireOrDescribe(specific is ConeKotlinType, specific)
requireOrDescribe(general is ConeKotlinType, general)
// TODO: support unsigned types
// see OverloadingConflictResolver.kt:294
val int = StandardClassIds.Int
val long = StandardClassIds.Long
val byte = StandardClassIds.Byte
@@ -87,7 +84,6 @@ abstract class AbstractConeCallConflictResolver(
// int >= long, int >= short, short >= byte
when {
//TypeUtils.equalTypes(specific, _double) && TypeUtils.equalTypes(general, _float) -> return true
specificClassId == int -> {
when (generalClassId) {
long -> return true
@@ -104,6 +100,7 @@ abstract class AbstractConeCallConflictResolver(
}
}
specificClassId == uShort && generalClassId == uByte -> return true
specificClassId == StandardClassIds.Double && generalClassId == StandardClassIds.Float -> return true
}
return false
}
@@ -0,0 +1,20 @@
// FIR_IDENTICAL
// SKIP_TXT
// DIAGNOSTICS: -USELESS_IS_CHECK, -DEBUG_INFO_SMARTCAST
// ISSUE: KT-57194
fun foo(arg: Double) {}
fun foo(arg: Float) {}
fun Double.bar() {}
fun Float.bar() {}
fun test(arg: Any) {
::foo
if (arg is Double) {
if (arg is Float) {
foo(arg)
arg.bar()
}
}
}
@@ -23480,6 +23480,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
}
@Test
@TestMetadata("doubleWinsOverFloat.kt")
public void testDoubleWinsOverFloat() throws Exception {
runTest("compiler/testData/diagnostics/tests/overload/doubleWinsOverFloat.kt");
}
@Test
@TestMetadata("EmptyArgumentListInLambda.kt")
public void testEmptyArgumentListInLambda() throws Exception {