From bd826f38bc7c87cca8614244dbf86183014acd22 Mon Sep 17 00:00:00 2001 From: "simon.ogorodnik" Date: Wed, 1 Apr 2020 20:43:27 +0300 Subject: [PATCH] [FIR] Fix specificity comparision for unsigned integers --- .../calls/AbstractConeCallConflictResolver.kt | 16 ++++++++++++++++ .../codegen/box/ranges/unsigned/kt36953.kt | 1 - .../box/ranges/unsigned/kt36953_continue.kt | 1 - 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt index 76a79491687..d6225dd2abb 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/AbstractConeCallConflictResolver.kt @@ -69,9 +69,17 @@ abstract class AbstractConeCallConflictResolver( val byte = StandardClassIds.Byte val short = StandardClassIds.Short + val uInt = StandardClassIds.UInt + val uLong = StandardClassIds.ULong + val uByte = StandardClassIds.UByte + val uShort = StandardClassIds.UShort + val specificClassId = specific.classId ?: return false val generalClassId = general.classId ?: return false + + // int >= long, int >= short, short >= byte + when { //TypeUtils.equalTypes(specific, _double) && TypeUtils.equalTypes(general, _float) -> return true specificClassId == int -> { @@ -82,6 +90,14 @@ abstract class AbstractConeCallConflictResolver( } } specificClassId == short && generalClassId == byte -> return true + specificClassId == uInt -> { + when { + generalClassId == uLong -> return true + generalClassId == uByte -> return true + generalClassId == uShort -> return true + } + } + specificClassId == uShort && generalClassId == uByte -> return true } return false } diff --git a/compiler/testData/codegen/box/ranges/unsigned/kt36953.kt b/compiler/testData/codegen/box/ranges/unsigned/kt36953.kt index 7d86ce2dcbe..61b204783d0 100644 --- a/compiler/testData/codegen/box/ranges/unsigned/kt36953.kt +++ b/compiler/testData/codegen/box/ranges/unsigned/kt36953.kt @@ -1,6 +1,5 @@ // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR fun testBreak() { for (i in 0..1) { diff --git a/compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt b/compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt index 1c2ea81d4f1..946822fe2d1 100644 --- a/compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt +++ b/compiler/testData/codegen/box/ranges/unsigned/kt36953_continue.kt @@ -1,6 +1,5 @@ // WITH_RUNTIME // KJS_WITH_FULL_RUNTIME -// IGNORE_BACKEND_FIR: JVM_IR fun testContinue() { for (i in 0..1) {