Open som-snytt opened 1 year ago
Scala version: 2.13.10
class C { final val x = 42 final val y: 42 = 42 def f = x def g = y def f2 = x+1 def g2 = y+1 }
Scala 3 correctly does the same for both, which is no field.
Scala 2 incorrectly or suboptimally has field for y and accessor is invoked for g, but g2 is constant-folded (during type checking).
Noticed at https://github.com/cquiroz/scala-java-time/pull/403#issuecomment-1309909556 where
It's hard to reason about this.
Of course, inline addresses these concerns.
inline
Reproduction steps
Scala version: 2.13.10
Problem
Scala 3 correctly does the same for both, which is no field.
Scala 2 incorrectly or suboptimally has field for y and accessor is invoked for g, but g2 is constant-folded (during type checking).
Noticed at https://github.com/cquiroz/scala-java-time/pull/403#issuecomment-1309909556 where
Of course,
inline
addresses these concerns.