Skip to content

Commit 6c7ac2f

Browse files
committed
Fix #5441: Java semantics for operations on Long with Float arg
1 parent 99548bd commit 6c7ac2f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

compiler/src/dotty/tools/backend/jvm/BTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ abstract class BTypes {
291291

292292
case LONG =>
293293
if (other.isIntegralType) LONG
294-
else if (other.isRealType) DOUBLE
294+
else if (other.isRealType) other
295295
else uncomparable
296296

297297
case FLOAT =>

tests/run/i5441.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1.164309
2+
1.164309
3+
2.3242621

tests/run/i5441.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object Test {
2+
def main(args: Array[String]): Unit =
3+
def a(): Float = java.lang.Float.intBitsToFloat(1079290514)
4+
def b(): Long = 1412906027847L
5+
println(b() % a())
6+
println((b().toFloat % a().toFloat).toFloat)
7+
println((b().toDouble % a().toDouble).toFloat)
8+
}

0 commit comments

Comments
 (0)