@@ -718,9 +718,9 @@ class JSCodeGen()(implicit ctx: Context) {
718718 if (sym.is(Module )) {
719719 assert(! sym.is(Package ), " Cannot use package as value: " + tree)
720720 genLoadModule(sym)
721- } else /* if (sym.isStaticMember ) {
722- genStaticMember (sym)
723- } else if (paramAccessorLocals contains sym) {
721+ } else if (sym.is( JavaStatic ) ) {
722+ genLoadStaticField (sym)
723+ } else /* if (paramAccessorLocals contains sym) {
724724 paramAccessorLocals(sym).ref
725725 } else if (isScalaJSDefinedJSClass(sym.owner)) {
726726 val genQual = genExpr(qualifier)
@@ -1036,8 +1036,6 @@ class JSCodeGen()(implicit ctx: Context) {
10361036 genStringConcat(tree, receiver, args)
10371037 else if (code == HASH )
10381038 genScalaHash(tree, receiver)
1039- else if (isArrayNew(code))
1040- genArrayNew(tree, code)
10411039 else if (isArrayOp(code))
10421040 genArrayOp(tree, code)
10431041 else if (code == SYNCHRONIZED )
@@ -1409,24 +1407,6 @@ class JSCodeGen()(implicit ctx: Context) {
14091407 List (genExpr(receiver)))
14101408 }
14111409
1412- /** Gen JS code for a new array operation. */
1413- private def genArrayNew (tree : Tree , code : Int ): js.Tree = {
1414- import scala .tools .nsc .backend .ScalaPrimitives ._
1415-
1416- implicit val pos : Position = tree.pos
1417-
1418- val Apply (fun, args) = tree
1419- val genLength = genExpr(args.head)
1420-
1421- toIRType(tree.tpe) match {
1422- case arrayType : jstpe.ArrayType =>
1423- js.NewArray (arrayType, List (genLength))
1424-
1425- case irTpe =>
1426- throw new FatalError (s " ArrayNew $tree must have an array type but was $irTpe" )
1427- }
1428- }
1429-
14301410 /** Gen JS code for an array operation (get, set or length) */
14311411 private def genArrayOp (tree : Tree , code : Int ): js.Tree = {
14321412 import scala .tools .nsc .backend .ScalaPrimitives ._
@@ -2328,6 +2308,24 @@ class JSCodeGen()(implicit ctx: Context) {
23282308 }
23292309 }
23302310
2311+ /** Gen JS code for loading a Java static field.
2312+ */
2313+ private def genLoadStaticField (sym : Symbol )(implicit pos : Position ): js.Tree = {
2314+ /* Actually, there is no static member in Scala.js. If we come here, that
2315+ * is because we found the symbol in a Java-emitted .class in the
2316+ * classpath. But the corresponding implementation in Scala.js will
2317+ * actually be a val in the companion module.
2318+ */
2319+
2320+ if (sym == defn.BoxedUnit_UNIT ) {
2321+ js.Undefined ()
2322+ } else {
2323+ val instance = genLoadModule(sym.owner)
2324+ val method = encodeStaticMemberSym(sym)
2325+ js.Apply (instance, method, Nil )(toIRType(sym.info))
2326+ }
2327+ }
2328+
23312329 /** Gen JS code for loading a module.
23322330 *
23332331 * Can be given either the module symbol, or its module class symbol.
0 commit comments