-
-
Notifications
You must be signed in to change notification settings - Fork 118
Support Scala 3 #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Scala 3 #226
Conversation
There is a bug in the dotty compiler? scala/scala3#13518 scalatags.js[3.0.1,1.7.0].compile java.lang.AssertionError: assertion failed scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) dotty.tools.backend.sjs.JSCodeGen.genStringConcat(JSCodeGen.scala:2487) dotty.tools.backend.sjs.JSCodeGen.genPrimitiveOp(JSCodeGen.scala:2098)
@@ -32,58 +32,58 @@ trait DataConverters{ | |||
* | |||
* MDN | |||
*/ | |||
def px = x + "px" | |||
def px = x.toString + "px" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo this would look a little nicer as
def px = s"${x}px"
Just personal opinion though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agree!
inline def apply[T <: StyleSheet]: SourceClasses[T] = $ { manglerImpl[T] } | ||
|
||
def manglerImpl[T <: StyleSheet: Type](using Quotes): Expr[SourceClasses[T]] = { | ||
' { new SourceClasses[T]((t: T) => ${ Expr.ofSeq(terms('t)) }) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github's code highlighting doesn't seem to be aware of the new quotes syntax 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would be a good bug report over at https://github.com/scala/vscode-scala-syntax/issues (repo name says "vscode", but it also powers highlighting on GitHub)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion @SethTisue 🙂
I opened an issue as you suggested and opened also a PR with a fix.
Issue: scala/vscode-scala-syntax#226, PR: scala/vscode-scala-syntax#227
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow even better!
scalatags/src/scalatags/Text.scala
Outdated
// Scala 3 behaviour prevents us from using the same name as the case | ||
// class for some reason, thus also preventing us from using the | ||
// auto-generated companion object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works fine in 3.0.2
, not sure what was the problem here.
Seems like Then we need to |
/** | ||
* A [[Modifier]] which contains a String which will not be escaped. | ||
*/ | ||
protected[this] type RawFrag <: Modifier | ||
protected[this] val RawFrag: Companion[RawFrag] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this and all the tests pass.
The way unapply works in Scala 3 is different from Scala 2 and it's hard to write it generically.
Does this have an usage @lihaoyi ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is generally used. People construct raw frags via raw(...)
, and generally we do not support or encourage de-constructing frags: they are to be constructed and rendered, with no other operations in between.
Thus we can probably do without this if it's too difficult. If removing it doesn't break the test suite, then we it probably won't be missed
I tried removing |
Tests pass now 🎉 |
@lolgab could you provide a verbose PR description of what the major changes are and why they are necessary? That would be a lot easier to review than trying to reverse engineer your intent from the raw code diff |
@lihaoyi Reverted some changed that are not necessary for Scala 3 tests to pass. |
Do you know if this is an inherent limitation of the utest macro, or is it something that could be fixed in utest for scala 3? Not a blocker, but I'm just curious |
@jodersky I don't know, sorry. |
@lolgab don't these scala specific folders have to be |
Co-authored-by: Sakib Hadžiavdić <sake92@users.noreply.github.com>
Mill splits the version by |
I think this generally looks good to me. @sake92 I know you've made some efforts around Scala3, if you could give this pR your approval then I think we're good to merge |
@lihaoyi Yep, all looks good I think. |
Great. @lolgab go ahead and merge whenever you're ready :) |
This PR is built on top of the commits by @edwardcwang.
Changes:
0.9.10
and fix build deprecationsscalaMajorVersion
in buildInfoMembers since Scala 3 represents types wrapped inside()
in error messages.ev: A => Frag
in various implicit classes (likeSeqFrag
) since Scala 3 doesn't apply implicitly.protected[this] val RawFrag: Companion[RawFrag]
andprotected[this] val StringFrag: Companion[StringFrag]
since they break variance and Scala 3 is much less permissive with variance. Overriding them with strictier types in subclasses result in compiler errors. Since this was the only use case ofCompanion
I removed it as well. Also I failed to representCompanion
in Scala 3 since it uses different signatures forunapply
implicit
fields as required by Scala 3.def +(other: Any): String
in classString
with String interpolator since it is not supported in Scala 3Tags.scala
,Tags2.scala
andSvgTags.scala
def
s instead ofval
s since Scala 3 doesn't support overriding an abstractval
member with alazy val
as Scalatags does.SourceClasses
class and its companion object to the version specific code. Since it is the only code using macros.* -
utest syntax. Also not supported in Scala 3.