Skip to content

Commit 8ebef0f

Browse files
committed
Upgrade to Scala.js 1.16.0.
Code changes are forward ports of the following refactorings: * Remove the parameters to StoreModule IR nodes. scala-js/scala-js@659d518 * Refactor: Make FieldName a composite of ClassName and SimpleFieldName. scala-js/scala-js@723663b
1 parent 78f3eeb commit 8ebef0f

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

Diff for: compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

+6-10
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ class JSCodeGen()(using genCtx: Context) {
927927
val className = encodeClassName(classSym)
928928
val body = js.Block(
929929
js.LoadModule(className),
930-
js.SelectStatic(className, fieldIdent)(irTpe))
930+
js.SelectStatic(fieldIdent)(irTpe))
931931
staticGetterDefs += js.MethodDef(
932932
js.MemberFlags.empty.withNamespace(js.MemberNamespace.PublicStatic),
933933
encodeStaticMemberSym(f), originalName, Nil, irTpe,
@@ -2243,10 +2243,7 @@ class JSCodeGen()(using genCtx: Context) {
22432243
if (isStaticModule(currentClassSym) && !isModuleInitialized.get.value &&
22442244
currentMethodSym.get.isClassConstructor) {
22452245
isModuleInitialized.get.value = true
2246-
val className = encodeClassName(currentClassSym)
2247-
val thisType = jstpe.ClassType(className)
2248-
val initModule = js.StoreModule(className, js.This()(thisType))
2249-
js.Block(superCall, initModule)
2246+
js.Block(superCall, js.StoreModule())
22502247
} else {
22512248
superCall
22522249
}
@@ -4463,13 +4460,12 @@ class JSCodeGen()(using genCtx: Context) {
44634460
js.JSSelect(qual, genPrivateFieldsSymbol()),
44644461
encodeFieldSymAsStringLiteral(sym))
44654462
} else {
4466-
js.JSPrivateSelect(qual, encodeClassName(sym.owner),
4467-
encodeFieldSym(sym))
4463+
js.JSPrivateSelect(qual, encodeFieldSym(sym))
44684464
}
44694465

44704466
(f, true)
44714467
} else if (sym.hasAnnotation(jsdefn.JSExportTopLevelAnnot)) {
4472-
val f = js.SelectStatic(encodeClassName(sym.owner), encodeFieldSym(sym))(jstpe.AnyType)
4468+
val f = js.SelectStatic(encodeFieldSym(sym))(jstpe.AnyType)
44734469
(f, true)
44744470
} else if (sym.hasAnnotation(jsdefn.JSExportStaticAnnot)) {
44754471
val jsName = sym.getAnnotation(jsdefn.JSExportStaticAnnot).get.argumentConstantString(0).getOrElse {
@@ -4495,9 +4491,9 @@ class JSCodeGen()(using genCtx: Context) {
44954491

44964492
val f =
44974493
if sym.is(JavaStatic) then
4498-
js.SelectStatic(className, fieldIdent)(irType)
4494+
js.SelectStatic(fieldIdent)(irType)
44994495
else
4500-
js.Select(qual, className, fieldIdent)(irType)
4496+
js.Select(qual, fieldIdent)(irType)
45014497

45024498
(f, boxed)
45034499
}

Diff for: compiler/src/dotty/tools/backend/sjs/JSEncoding.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import dotty.tools.dotc.transform.sjs.JSSymUtils.*
1717

1818
import org.scalajs.ir
1919
import org.scalajs.ir.{Trees => js, Types => jstpe}
20-
import org.scalajs.ir.Names.{LocalName, LabelName, FieldName, SimpleMethodName, MethodName, ClassName}
20+
import org.scalajs.ir.Names.{LocalName, LabelName, SimpleFieldName, FieldName, SimpleMethodName, MethodName, ClassName}
2121
import org.scalajs.ir.OriginalName
2222
import org.scalajs.ir.OriginalName.NoOriginalName
2323
import org.scalajs.ir.UTF8String
@@ -173,7 +173,7 @@ object JSEncoding {
173173
}
174174

175175
def encodeFieldSym(sym: Symbol)(implicit ctx: Context, pos: ir.Position): js.FieldIdent =
176-
js.FieldIdent(FieldName(encodeFieldSymAsString(sym)))
176+
js.FieldIdent(FieldName(encodeClassName(sym.owner), SimpleFieldName(encodeFieldSymAsString(sym))))
177177

178178
def encodeFieldSymAsStringLiteral(sym: Symbol)(implicit ctx: Context, pos: ir.Position): js.StringLiteral =
179179
js.StringLiteral(encodeFieldSymAsString(sym))

Diff for: project/Build.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,8 @@ object Build {
15081508
"isNoModule" -> (moduleKind == ModuleKind.NoModule),
15091509
"isESModule" -> (moduleKind == ModuleKind.ESModule),
15101510
"isCommonJSModule" -> (moduleKind == ModuleKind.CommonJSModule),
1511-
"isFullOpt" -> (stage == FullOptStage),
1511+
"usesClosureCompiler" -> linkerConfig.closureCompiler,
1512+
"hasMinifiedNames" -> (linkerConfig.closureCompiler || linkerConfig.minify),
15121513
"compliantAsInstanceOfs" -> (sems.asInstanceOfs == CheckedBehavior.Compliant),
15131514
"compliantArrayIndexOutOfBounds" -> (sems.arrayIndexOutOfBounds == CheckedBehavior.Compliant),
15141515
"compliantArrayStores" -> (sems.arrayStores == CheckedBehavior.Compliant),

Diff for: project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
libraryDependencySchemes +=
77
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
88

9-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.15.0")
9+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.16.0")
1010

1111
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21")
1212

0 commit comments

Comments
 (0)