[FIR] Prioritize double over float in overload resolution
#KT-57194 Fixed
This commit is contained in:
committed by
Space Team
parent
525317962c
commit
fa432d7f0d
+6
@@ -23474,6 +23474,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
|
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
|
@Test
|
||||||
@TestMetadata("EmptyArgumentListInLambda.kt")
|
@TestMetadata("EmptyArgumentListInLambda.kt")
|
||||||
public void testEmptyArgumentListInLambda() throws Exception {
|
public void testEmptyArgumentListInLambda() throws Exception {
|
||||||
|
|||||||
+6
@@ -23474,6 +23474,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
|
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
|
@Test
|
||||||
@TestMetadata("EmptyArgumentListInLambda.kt")
|
@TestMetadata("EmptyArgumentListInLambda.kt")
|
||||||
public void testEmptyArgumentListInLambda() throws Exception {
|
public void testEmptyArgumentListInLambda() throws Exception {
|
||||||
|
|||||||
+6
@@ -23480,6 +23480,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
|
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
|
@Test
|
||||||
@TestMetadata("EmptyArgumentListInLambda.kt")
|
@TestMetadata("EmptyArgumentListInLambda.kt")
|
||||||
public void testEmptyArgumentListInLambda() throws Exception {
|
public void testEmptyArgumentListInLambda() throws Exception {
|
||||||
|
|||||||
+1
-4
@@ -67,9 +67,6 @@ abstract class AbstractConeCallConflictResolver(
|
|||||||
requireOrDescribe(specific is ConeKotlinType, specific)
|
requireOrDescribe(specific is ConeKotlinType, specific)
|
||||||
requireOrDescribe(general is ConeKotlinType, general)
|
requireOrDescribe(general is ConeKotlinType, general)
|
||||||
|
|
||||||
// TODO: support unsigned types
|
|
||||||
// see OverloadingConflictResolver.kt:294
|
|
||||||
|
|
||||||
val int = StandardClassIds.Int
|
val int = StandardClassIds.Int
|
||||||
val long = StandardClassIds.Long
|
val long = StandardClassIds.Long
|
||||||
val byte = StandardClassIds.Byte
|
val byte = StandardClassIds.Byte
|
||||||
@@ -87,7 +84,6 @@ abstract class AbstractConeCallConflictResolver(
|
|||||||
// int >= long, int >= short, short >= byte
|
// int >= long, int >= short, short >= byte
|
||||||
|
|
||||||
when {
|
when {
|
||||||
//TypeUtils.equalTypes(specific, _double) && TypeUtils.equalTypes(general, _float) -> return true
|
|
||||||
specificClassId == int -> {
|
specificClassId == int -> {
|
||||||
when (generalClassId) {
|
when (generalClassId) {
|
||||||
long -> return true
|
long -> return true
|
||||||
@@ -104,6 +100,7 @@ abstract class AbstractConeCallConflictResolver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
specificClassId == uShort && generalClassId == uByte -> return true
|
specificClassId == uShort && generalClassId == uByte -> return true
|
||||||
|
specificClassId == StandardClassIds.Double && generalClassId == StandardClassIds.Float -> return true
|
||||||
}
|
}
|
||||||
return false
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+6
@@ -23480,6 +23480,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/overload/disambiguateByFailedAbstractClassCheck.kt");
|
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
|
@Test
|
||||||
@TestMetadata("EmptyArgumentListInLambda.kt")
|
@TestMetadata("EmptyArgumentListInLambda.kt")
|
||||||
public void testEmptyArgumentListInLambda() throws Exception {
|
public void testEmptyArgumentListInLambda() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user