Skip to content

Scala 2 vs Scala 3 compiler regression when calling isNaN on a double #24128

@tewecske

Description

@tewecske

Compiler version

2.13.x vs 3.x.x

Minimized code

//> using scala 3.x.x

object Square {
  val d = 1.01
  d.isNaN
}

Output

https://godbolt.org/z/xx4srTTh1

In Scala 3 the isNaN call is not optimized and there is a double2Double call which does boxing and triggers gc calls.

invokevirtual #36                 // Method scala/Predef$.double2Double:(D)Ljava/lang/Double;
invokevirtual #42                 // Method java/lang/Double.isNaN:()Z

Expectation

In Scala 2 the compiled bytecode calls the static Double.isNaN

invokestatic  #29                 // Method java/lang/Double.isNaN:(D)Z

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions