Skip to content
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
13 changes: 11 additions & 2 deletions compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ class JSCodeGen()(using genCtx: Context) {
/* This is a default parameter whose assignment was moved to
* a local variable. Put an undefined param instead.
*/
js.Transient(UndefinedParam)(toIRType(sym.info))
js.Transient(UndefinedParam)
} else {
js.VarRef(encodeLocalSym(sym))(toIRType(sym.info))
}
Expand Down Expand Up @@ -1691,7 +1691,7 @@ class JSCodeGen()(using genCtx: Context) {

fun match {
case _ if sym.isJSDefaultParam =>
js.Transient(UndefinedParam)(toIRType(sym.info.finalResultType))
js.Transient(UndefinedParam)

case Select(Super(_, _), _) =>
genSuperCall(tree, isStat)
Expand Down Expand Up @@ -4306,6 +4306,15 @@ object JSCodeGen {
* To be used inside a `js.Transient` node.
*/
case object UndefinedParam extends js.Transient.Value {
val tpe: jstpe.Type = jstpe.UndefType

def traverse(traverser: ir.Traversers.Traverser): Unit = ()

def transform(transformer: ir.Transformers.Transformer, isStat: Boolean)(
implicit pos: ir.Position): js.Tree = {
js.Transient(this)
}

def printIR(out: ir.Printers.IRTreePrinter): Unit =
out.print("<undefined-param>")
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,10 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {

if (targetSym.isJSType) {
if (defaultGetter.owner.isNonNativeJSClass) {
genApplyJSClassMethod(targetTree, defaultGetter, defaultGetterArgs)
if (defaultGetter.hasAnnotation(jsdefn.JSOptionalAnnot))
js.Undefined()
else
genApplyJSClassMethod(targetTree, defaultGetter, defaultGetterArgs)
} else {
report.error(
"When overriding a native method with default arguments, " +
Expand Down
10 changes: 6 additions & 4 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1148,12 +1148,14 @@ object Build {
},

managedSources in Compile ++= {
val dir = fetchScalaJSSource.value / "test-suite/js/src/main/scala"
val filter = (
("*.scala": FileFilter)
val dir = fetchScalaJSSource.value
(
(dir / "test-suite/js/src/main/scala" ** (("*.scala": FileFilter)
-- "Typechecking*.scala" // defines a Scala 2 macro
)).get

++ (dir / "junit-async/js/src/main/scala" ** "*.scala").get
)
(dir ** filter).get
},

// A first blacklist of tests for those that do not compile or do not link
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.3.1")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.4.0")

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

Expand Down