Skip to content

Commit

Permalink
Upgrade to Scala.js 1.16.0.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sjrd committed Apr 29, 2024
1 parent edb2faf commit 8449f19
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
16 changes: 6 additions & 10 deletions compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ class JSCodeGen()(using genCtx: Context) {
val className = encodeClassName(classSym)
val body = js.Block(
js.LoadModule(className),
js.SelectStatic(className, fieldIdent)(irTpe))
js.SelectStatic(fieldIdent)(irTpe))
staticGetterDefs += js.MethodDef(
js.MemberFlags.empty.withNamespace(js.MemberNamespace.PublicStatic),
encodeStaticMemberSym(f), originalName, Nil, irTpe,
Expand Down Expand Up @@ -2243,10 +2243,7 @@ class JSCodeGen()(using genCtx: Context) {
if (isStaticModule(currentClassSym) && !isModuleInitialized.get.value &&
currentMethodSym.get.isClassConstructor) {
isModuleInitialized.get.value = true
val className = encodeClassName(currentClassSym)
val thisType = jstpe.ClassType(className)
val initModule = js.StoreModule(className, js.This()(thisType))
js.Block(superCall, initModule)
js.Block(superCall, js.StoreModule())
} else {
superCall
}
Expand Down Expand Up @@ -4463,13 +4460,12 @@ class JSCodeGen()(using genCtx: Context) {
js.JSSelect(qual, genPrivateFieldsSymbol()),
encodeFieldSymAsStringLiteral(sym))
} else {
js.JSPrivateSelect(qual, encodeClassName(sym.owner),
encodeFieldSym(sym))
js.JSPrivateSelect(qual, encodeFieldSym(sym))
}

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

val f =
if sym.is(JavaStatic) then
js.SelectStatic(className, fieldIdent)(irType)
js.SelectStatic(fieldIdent)(irType)
else
js.Select(qual, className, fieldIdent)(irType)
js.Select(qual, fieldIdent)(irType)

(f, boxed)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/backend/sjs/JSEncoding.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import dotty.tools.dotc.transform.sjs.JSSymUtils.*

import org.scalajs.ir
import org.scalajs.ir.{Trees => js, Types => jstpe}
import org.scalajs.ir.Names.{LocalName, LabelName, FieldName, SimpleMethodName, MethodName, ClassName}
import org.scalajs.ir.Names.{LocalName, LabelName, SimpleFieldName, FieldName, SimpleMethodName, MethodName, ClassName}
import org.scalajs.ir.OriginalName
import org.scalajs.ir.OriginalName.NoOriginalName
import org.scalajs.ir.UTF8String
Expand Down Expand Up @@ -173,7 +173,7 @@ object JSEncoding {
}

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

def encodeFieldSymAsStringLiteral(sym: Symbol)(implicit ctx: Context, pos: ir.Position): js.StringLiteral =
js.StringLiteral(encodeFieldSymAsString(sym))
Expand Down
3 changes: 2 additions & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1508,7 +1508,8 @@ object Build {
"isNoModule" -> (moduleKind == ModuleKind.NoModule),
"isESModule" -> (moduleKind == ModuleKind.ESModule),
"isCommonJSModule" -> (moduleKind == ModuleKind.CommonJSModule),
"isFullOpt" -> (stage == FullOptStage),
"usesClosureCompiler" -> linkerConfig.closureCompiler,
"hasMinifiedNames" -> (linkerConfig.closureCompiler || linkerConfig.minify),
"compliantAsInstanceOfs" -> (sems.asInstanceOfs == CheckedBehavior.Compliant),
"compliantArrayIndexOutOfBounds" -> (sems.arrayIndexOutOfBounds == CheckedBehavior.Compliant),
"compliantArrayStores" -> (sems.arrayStores == CheckedBehavior.Compliant),
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
libraryDependencySchemes +=
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always

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

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

Expand Down

0 comments on commit 8449f19

Please sign in to comment.