-Rational.one triggers deprecation warning about auto-application in 2.13.3
Closed this issue · 4 comments
Scala 2.13.3 deprecates auto-application of methods with empty parameter lists, see scala/scala#8833. Spire defines the unary -
of Rational
with an empty parameter list. Consequently negating a rational (i.e. -Rational.one
) triggers the new deprecation warning, e.g. (with import spire.math.{Rational => R})
:
Error:(49, 25) Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method unary_-,
or remove the empty argument list from its definition (Java-defined methods are exempt).
In Scala 3, an unapplied method like this will be eta-expanded into a function.
SnapToGrid(R.one, -R.one, Closed(R.zero))
I'm not sure whether this can be considered a bug in Scala 2.13.3, but it looks as if just removing the empty parameter list from spire.match.Rational.unary_-
(i.e. defining it without any argument list) would fix this issue on the Spire side. Other numeric types in Spire (e.g. UByte
) already define the unary - without parameter lists.
Yeah, good point. This will be an error in Dotty. Would you mind sending a PR?
To remove these parenthesis? Can do next week, please ping me on eg Thursday should I forget 🙂
I mean, there's many other occurrences of unary_-()
, so help would be appreciated 😉
Should be fixed now.