Skip to content

Commit e871ba9

Browse files
authored
Merge pull request #14631 from lampepfl/revert-14610-scalajs-1.9.0
Revert "Upgrade to Scala.js 1.9.0."
2 parents 9abe753 + b9bea76 commit e871ba9

File tree

6 files changed

+15
-119
lines changed

6 files changed

+15
-119
lines changed

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,14 +4563,7 @@ class JSCodeGen()(using genCtx: Context) {
45634563
val module = annot.argumentConstantString(0).getOrElse {
45644564
unexpected("could not read the module argument as a string literal")
45654565
}
4566-
val path = annot.argumentConstantString(1).fold {
4567-
if (annot.arguments.sizeIs < 2)
4568-
parsePath(sym.defaultJSName)
4569-
else
4570-
Nil
4571-
} { pathName =>
4572-
parsePath(pathName)
4573-
}
4566+
val path = annot.argumentConstantString(1).fold[List[String]](Nil)(parsePath)
45744567
val importSpec = Import(module, path)
45754568
annot.argumentConstantString(2).fold[js.JSNativeLoadSpec] {
45764569
importSpec

compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ import Contexts._
1414
import Decorators._
1515
import DenotTransformers._
1616
import Flags._
17-
import NameKinds.{DefaultGetterName, ModuleClassName}
18-
import NameOps._
17+
import NameKinds.DefaultGetterName
1918
import StdNames._
2019
import Symbols._
2120
import SymUtils._
@@ -560,14 +559,9 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
560559
case Some(annot) if annot.symbol == jsdefn.JSGlobalAnnot =>
561560
checkJSGlobalLiteral(annot)
562561
val pathName = annot.argumentConstantString(0).getOrElse {
563-
val symTermName = sym.name.exclude(NameKinds.ModuleClassName).toTermName
564-
if (symTermName == nme.apply) {
562+
if ((enclosingOwner is OwnerKind.ScalaMod) && !sym.owner.isPackageObject) {
565563
report.error(
566-
"Native JS definitions named 'apply' must have an explicit name in @JSGlobal",
567-
annot.tree)
568-
} else if (symTermName.isSetterName) {
569-
report.error(
570-
"Native JS definitions with a name ending in '_=' must have an explicit name in @JSGlobal",
564+
"Native JS members inside non-native objects must have an explicit name in @JSGlobal",
571565
annot.tree)
572566
}
573567
sym.defaultJSName
@@ -576,18 +570,6 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
576570

577571
case Some(annot) if annot.symbol == jsdefn.JSImportAnnot =>
578572
checkJSImportLiteral(annot)
579-
if (annot.arguments.sizeIs < 2) {
580-
val symTermName = sym.name.exclude(NameKinds.ModuleClassName).toTermName
581-
if (symTermName == nme.apply) {
582-
report.error(
583-
"Native JS definitions named 'apply' must have an explicit name in @JSImport",
584-
annot.tree)
585-
} else if (symTermName.isSetterName) {
586-
report.error(
587-
"Native JS definitions with a name ending in '_=' must have an explicit name in @JSImport",
588-
annot.tree)
589-
}
590-
}
591573
annot.argumentConstantString(2).foreach { globalPathName =>
592574
checkGlobalRefPath(globalPathName)
593575
}
@@ -1125,19 +1107,18 @@ object PrepJSInterop {
11251107
*/
11261108
private def checkJSImportLiteral(annot: Annotation)(using Context): Unit = {
11271109
val args = annot.arguments
1128-
val argCount = args.size
1129-
assert(argCount >= 1 && argCount <= 3,
1130-
i"@JSImport annotation $annot does not have between 1 and 3 arguments")
1110+
assert(args.size == 2 || args.size == 3,
1111+
i"@JSImport annotation $annot does not have exactly 2 or 3 arguments")
11311112

11321113
val firstArgIsValid = annot.argumentConstantString(0).isDefined
11331114
if (!firstArgIsValid)
11341115
report.error("The first argument to @JSImport must be a literal string.", args.head)
11351116

1136-
val secondArgIsValid = argCount < 2 || annot.argumentConstantString(1).isDefined || args(1).symbol == jsdefn.JSImportNamespaceModule
1117+
val secondArgIsValid = annot.argumentConstantString(1).isDefined || args(1).symbol == jsdefn.JSImportNamespaceModule
11371118
if (!secondArgIsValid)
11381119
report.error("The second argument to @JSImport must be literal string or the JSImport.Namespace object.", args(1))
11391120

1140-
val thirdArgIsValid = argCount < 3 || annot.argumentConstantString(2).isDefined
1121+
val thirdArgIsValid = args.size < 3 || annot.argumentConstantString(2).isDefined
11411122
if (!thirdArgIsValid)
11421123
report.error("The third argument to @JSImport, when present, must be a literal string.", args(2))
11431124
}

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ object Build {
5959

6060
val referenceVersion = "3.1.2-RC1"
6161

62-
val baseVersion = "3.2.0-RC1"
62+
val baseVersion = "3.1.3-RC1"
6363

6464
// Versions used by the vscode extension to create a new project
6565
// This should be the latest published releases.

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// e.g. addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0")
44

5-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.9.0")
5+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.7.1")
66

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

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,8 @@
11
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:6:2 ----------------------------------------------
22
6 | @JSGlobal // error
33
| ^^^^^^^^^
4-
| Native JS definitions named 'apply' must have an explicit name in @JSGlobal
4+
| Native JS members inside non-native objects must have an explicit name in @JSGlobal
55
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:10:2 ---------------------------------------------
66
10 | @JSGlobal // error
77
| ^^^^^^^^^
8-
| Native JS definitions named 'apply' must have an explicit name in @JSGlobal
9-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:14:2 ---------------------------------------------
10-
14 | @JSGlobal // error
11-
| ^^^^^^^^^
12-
| Native JS definitions with a name ending in '_=' must have an explicit name in @JSGlobal
13-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:20:2 ---------------------------------------------
14-
20 | @JSGlobal // error
15-
| ^^^^^^^^^
16-
| Native JS definitions with a name ending in '_=' must have an explicit name in @JSGlobal
17-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:19:2 ---------------------------------------------
18-
19 | @js.native // error
19-
| ^^^^^^^^^^
20-
| @js.native is not allowed on vars, lazy vals and setter defs
21-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:24:2 ---------------------------------------------
22-
24 | @JSGlobal // error
23-
| ^^^^^^^^^
24-
| Native JS definitions named 'apply' must have an explicit name in @JSGlobal
25-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:30:3 ---------------------------------------------
26-
30 | @JSImport("bar.js") // error
27-
| ^^^^^^^^^^^^^^^^^^^
28-
| Native JS definitions named 'apply' must have an explicit name in @JSImport
29-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:34:3 ---------------------------------------------
30-
34 | @JSImport("bar.js") // error
31-
| ^^^^^^^^^^^^^^^^^^^
32-
| Native JS definitions named 'apply' must have an explicit name in @JSImport
33-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:38:3 ---------------------------------------------
34-
38 | @JSImport("bar.js") // error
35-
| ^^^^^^^^^^^^^^^^^^^
36-
| Native JS definitions with a name ending in '_=' must have an explicit name in @JSImport
37-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:44:3 ---------------------------------------------
38-
44 | @JSImport("bar.js") // error
39-
| ^^^^^^^^^^^^^^^^^^^
40-
| Native JS definitions with a name ending in '_=' must have an explicit name in @JSImport
41-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:43:2 ---------------------------------------------
42-
43 | @js.native // error
43-
| ^^^^^^^^^^
44-
| @js.native is not allowed on vars, lazy vals and setter defs
45-
-- Error: tests/neg-scalajs/native-load-spec-need-explicit-name.scala:48:3 ---------------------------------------------
46-
48 | @JSImport("bar.js") // error
47-
| ^^^^^^^^^^^^^^^^^^^
48-
| Native JS definitions named 'apply' must have an explicit name in @JSImport
8+
| Native JS members inside non-native objects must have an explicit name in @JSGlobal

tests/neg-scalajs/native-load-spec-need-explicit-name.scala

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,14 @@
11
import scala.scalajs.js
22
import scala.scalajs.js.annotation.*
33

4-
object A1 {
4+
object A {
55
@js.native
66
@JSGlobal // error
7-
class apply extends js.Object
7+
class B extends js.Object
88

99
@js.native
1010
@JSGlobal // error
11-
object apply extends js.Object
12-
13-
@js.native
14-
@JSGlobal // error
15-
class foo_= extends js.Object
16-
}
17-
18-
object A2 {
19-
@js.native // error
20-
@JSGlobal // error
21-
def foo_=(x: Int): Unit = js.native
22-
23-
@js.native
24-
@JSGlobal // error
25-
def apply(x: Int): Int = js.native
26-
}
27-
28-
object B1 {
29-
@js.native
30-
@JSImport("bar.js") // error
31-
class apply extends js.Object
32-
33-
@js.native
34-
@JSImport("bar.js") // error
35-
object apply extends js.Object
36-
37-
@js.native
38-
@JSImport("bar.js") // error
39-
class foo_= extends js.Object
40-
}
41-
42-
object B2 {
43-
@js.native // error
44-
@JSImport("bar.js") // error
45-
def foo_=(x: Int): Unit = js.native
46-
47-
@js.native
48-
@JSImport("bar.js") // error
49-
def apply(x: Int): Int = js.native
11+
object C extends js.Object
5012
}
5113

5214
// scala-js#2401

0 commit comments

Comments
 (0)