Make constants `inline val`?
armanbilge opened this issue · 5 comments
armanbilge commented
Came up in #592 (comment). H/t @smarter. The question is if we can make this change binary-compatibly.
armanbilge commented
In another project I tried inline val
ing an opaque type and got
inline value must have a literal constant type
So, I'm not sure this will work.
armanbilge commented
[error] -- Error: /workspace/scala-js-dom/dom/src/main/scala-3/org/scalajs/dom/AppendMode.scala:6:23
[error] 6 | inline val segments: AppendMode = "segments"
[error] | ^^^^^^^^^^
[error] | inline value must have a literal constant type
Closing unless somebody knows a workaround.
armanbilge commented
Aha! This works.
package org.scalajs.dom
opaque type AppendMode <: String = String
object AppendMode {
opaque type segments <: AppendMode = "segments"
inline val segments: segments = "segments"
val sequence: AppendMode = "sequence"
}
So, now its the bincompat question again.
armanbilge commented
Well, darn.
[error] dom: Failed binary compatibility check against org.scala-js:scalajs-dom_sjs1_3:2.0.0! Found 1 potential problems
[error] * method segments()java.lang.String in object org.scalajs.dom.AppendMode#package#AppendMode does not have a correspondent in current version
[error] filter with: ProblemFilters.exclude[DirectMissingMethodProblem]("org.scalajs.dom.AppendMode#package#AppendMode.segments")
armanbilge commented
Turns out this was never going to work anyway. See: