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