Open ekrich opened 3 years ago
If MyEnum.values
is (to be taken as) Java API, then it should benefit from all the usual paren-exemptions. It should not warn in Scala 2.
I disagree. Scala has the conventions that you should not use ()
if the method is immutable, i.e. could be a property. This differs from Java, but nobody would seriously propose to use length()
on Iterables just because Java uses it. And nobody would want to go back to toString()
. I don't see a difference with values
here. And I do see the problem that it would set a bad precedent and dilute our hard-gained conventions when to drop ()
.
@som-snytt's argument makes sense. It seems like there's a migration problem here, and the correct solution is to make the values
method exempt from missing-paren warnings.
Compiler version
Scala
3.0.0-M3
and2.13.4
When cross compiling
java.time
for Scala.js the following call site needs to be changed toMonth.values
to compile with Scala 3. https://github.com/ekrich/sjavatime/blob/master/sjavatime/shared/src/main/scala/java/time/LocalDate.scala#L408When the code is compiled with
2.13.4
then it causes a warning because our Scala 2 implementation includes()
:Expectation
When defining Java APIs in Scala.js and Scala Native, we define empty parameter list methods with
()
. Sinceenum
can be used to write Java APIs and thevalues()
method is a Java API method, it should be defined with()
s. Other applicable Java methods should also be changed to match.As per Sébastien Doeraene @sjrd 07:22 on the Dotty gitter channel.