You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scala 2 and 3 both warn when left-shifting an Int by a Long:
valz= (1:Int) <<33L
method << in class Int is deprecated since 2.12.7: shifting a value by a `Long` argument is deprecated (except when the value is a `Long`).
Call `toInt` on the argument to maintain the current behavior and avoid the deprecation warning.
Using literal types in Scala 2.13.4 at least still prints the warning:
valz:2=1<<33L
method << in class Int is deprecated (since 2.12.7): shifting a value by a `Long` argument is deprecated (except when the value is a `Long`).
Call `toInt` on the argument to maintain the current behavior and avoid the deprecation warning.
Minimized code
Scala 2 and 3 both warn when left-shifting an
Int
by aLong
:https://scastie.scala-lang.org/cdcgyKBlRCWY5K3kGbG4Tg
But there is no warning in Scala 3 when we don't upcast to
Int
:https://scastie.scala-lang.org/nfhS9dZbQ1yyKhZsGmx2Mg
Using
: Nothing
to see what the compiler knows about the types shows an overflow in the Literal type ofz
:https://scastie.scala-lang.org/CLAqsDtHSlKu05yvvKJhmw
Using literal types in Scala 2.13.4 at least still prints the warning:
https://scastie.scala-lang.org/5oZ4UEsNSzi02gxjh3n1sw
Expectation
I would expect a warning in Scala 3 like there is in Scala 2 (better yet would be an error if possible).
The text was updated successfully, but these errors were encountered: