Skip to content
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

Upgrade to Scala.js 1.10.1. #15713

Merged
merged 3 commits into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion community-build/community-projects/play-json
10 changes: 9 additions & 1 deletion compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,15 @@ class JSCodeGen()(using genCtx: Context) {
}

case Block(stats, expr) =>
js.Block(stats.map(genStat) :+ genStatOrExpr(expr, isStat))
// #15419 Collapse { <undefined-param>; BoxedUnit } to <undefined-param>
val genStatsAndExpr0 = stats.map(genStat(_)) :+ genStatOrExpr(expr, isStat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, style: did you add the underscore on purpose?

Suggested change
val genStatsAndExpr0 = stats.map(genStat(_)) :+ genStatOrExpr(expr, isStat)
val genStatsAndExpr0 = stats.map(genStat) :+ genStatOrExpr(expr, isStat)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I always add the underscore on purpose. For some reason I don't trust eta expansion 😅

val genStatsAndExpr = genStatsAndExpr0 match {
case (undefParam @ js.Transient(UndefinedParam)) :: js.Undefined() :: Nil =>
undefParam :: Nil
case _ =>
genStatsAndExpr0
}
js.Block(genStatsAndExpr)

case Typed(expr, _) =>
expr match {
Expand Down
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
// Pass previous arguments to defaultGetter
val defaultGetterArgs = previousArgsValues(defaultGetter.info.paramInfoss.head.size)

if (targetSym.isJSType) {
val callGetter = if (targetSym.isJSType) {
if (defaultGetter.owner.isNonNativeJSClass) {
if (defaultGetter.hasAnnotation(jsdefn.JSOptionalAnnot))
js.Undefined()
Expand All @@ -784,6 +784,12 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
} else {
genApplyMethod(targetTree, defaultGetter, defaultGetterArgs)
}

// #15419 If the getter returns void, we must "box" it by returning undefined
if (callGetter.tpe == jstpe.NoType)
js.Block(callGetter, js.Undefined())
else
callGetter
}

private def targetSymForDefaultGetter(sym: Symbol): Symbol =
Expand Down
1 change: 1 addition & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,7 @@ object Build {
++ (dir / "js/src/test/require-2.12" ** "*.scala").get
++ (dir / "js/src/test/require-sam" ** "*.scala").get
++ (dir / "js/src/test/scala-new-collections" ** "*.scala").get
++ (dir / "js/src/test/require-no-modules" ** "*.scala").get
)
},
)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// e.g. addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.1")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.10")

Expand Down