Closed j-mie6 closed 1 year ago
I've broadened the issue title, because a far more commonly used operator, !
, was affected
% cat C.scala
class C { def x = !true }
% /usr/local/scala/scala-2.13.11/bin/scalac -Vprint:typer C.scala
...
def x: Boolean = true.unary_!
...
% /usr/local/scala/scala-2.13.12/bin/scalac -Vprint:typer C.scala
...
def x: Boolean = false
...
Reproduction steps
Scala version: 2.13.10, 2.12.17
Problem
When examining the bytecode generated for this, the first 4 constants are folded as expected, however the final one,
c
, is not folded. On further investigation afinal val imm = ~x
will also not be folded, which suggesting folding with~
is the problem.Note that this is not an issue on 3.3.0