scala3
scala3 copied to clipboard
Fix #14488: Scala.js: Add compiler support for scala.Enumeration.
This is the same logic that is used in the Scala.js compiler plugin for Scala 2.
We catch ValDefs of the forms
val SomeField = Value
val SomeOtherField = Value(5)
and rewrite them as
val SomeField = Value("SomeField")
val SomeOtherField = Value(5, "SomeOtherField")
For calls to Value and new Val without name that we cannot rewrite, we emit warnings.
Play JSON actually actively tests for the presence of the bug: https://github.com/dotty-staging/play-json/blob/f65a409f4dc129f7adc72f048abbfbfc937a740f/play-json/js/src/test/scala-3/play/api/libs/json/EnumSpec.scala#L14-22 What am I supposed to do with that!?
@sjrd perhaps you could
set `play-json`.js / Test / unmanagedSources / excludeFilter := HiddenFileFilter || "EnumSpec.scala"`
a little trick I've employed about a million times in the Scala 2 community build
Change the test, I'd say, as it's tracking progression rather than spec or regression.
set `play-json`.js / Test / unmanagedSources / excludeFilter := HiddenFileFilter || "EnumSpec.scala"`a little trick I've employed about a million times in the Scala 2 community build
Thanks, I'm trying that now.
Change the test, I'd say, as it's tracking progression rather than spec or regression.
I guess that's also a possibility. But that means it's a commit in our fork that is neither a cherry-pick from upstream, nor something I can PR back upstream anytime soon. Is that OK?
Yep, or at least to me it is.
Yep, or at least to me it is.
Alright, that worked as well.
@dwijnand Would you mind reviewing this PR, perhaps? It's mostly a port of the Enum-related aspect of
https://github.com/scala-js/scala-js/blob/v1.10.1/compiler/src/main/scala/org/scalajs/nscplugin/PrepJSInterop.scala
Ping @dwijnand ?
Yep, will do, sorry.
Thanks 🙏