Skip to content

@static on SJS causes assertion failed: Trying to access the this of another class #19396

Closed
@armanbilge

Description

@armanbilge

Compiler version

3.4.0-RC1-bin-20240106-c15cc9c-NIGHTLY

Minimized code

//> using platform js
//> using scala 3.4.0-RC1-bin-20240106-c15cc9c-NIGHTLY

import scala.annotation.static

class Foo

object Foo {
  @static def foo = ???
}

class Bar {
  def bar = Foo.foo
}

Output (click arrow to expand)

java.lang.AssertionError: assertion failed: Trying to access the this of another class: tree.symbol = class Foo, class symbol = class Bar
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1791)
        at dotty.tools.backend.sjs.JSCodeGen.genExpr(JSCodeGen.scala:1653)
        at dotty.tools.backend.sjs.JSCodeGen.genNormalApply(JSCodeGen.scala:3056)
        at dotty.tools.backend.sjs.JSCodeGen.genApply(JSCodeGen.scala:2159)
        at dotty.tools.backend.sjs.JSCodeGen.genStatOrExpr(JSCodeGen.scala:1779)
        at dotty.tools.backend.sjs.JSCodeGen.genExpr(JSCodeGen.scala:1653)
        at dotty.tools.backend.sjs.JSCodeGen.genBody$1(JSCodeGen.scala:1583)
        at dotty.tools.backend.sjs.JSCodeGen.genMethodDef(JSCodeGen.scala:1588)
        at dotty.tools.backend.sjs.JSCodeGen.genMethodWithCurrentLocalNameScope$$anonfun$1(JSCodeGen.scala:1555)
        at dotty.tools.backend.sjs.JSCodeGen.withPerMethodBodyState$$anonfun$1(JSCodeGen.scala:107)
        at dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:33)
        at dotty.tools.backend.sjs.JSCodeGen.withPerMethodBodyState(JSCodeGen.scala:108)
        at dotty.tools.backend.sjs.JSCodeGen.genMethodWithCurrentLocalNameScope(JSCodeGen.scala:1561)
        at dotty.tools.backend.sjs.JSCodeGen.genMethod$$anonfun$1(JSCodeGen.scala:1415)
        at dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:33)
        at dotty.tools.backend.sjs.JSCodeGen.genMethod(JSCodeGen.scala:1416)
        at dotty.tools.backend.sjs.JSCodeGen.genScalaClass$$anonfun$2(JSCodeGen.scala:376)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.backend.sjs.JSCodeGen.genScalaClass(JSCodeGen.scala:381)
        at dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit$$anonfun$3$$anonfun$1(JSCodeGen.scala:246)
        at dotty.tools.backend.sjs.ScopedVar$.withScopedVars(ScopedVar.scala:33)
        at dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit$$anonfun$3(JSCodeGen.scala:250)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.backend.sjs.JSCodeGen.genCompilationUnit(JSCodeGen.scala:252)
        at dotty.tools.backend.sjs.JSCodeGen.run(JSCodeGen.scala:164)
        at dotty.tools.backend.sjs.GenSJSIR.run(GenSJSIR.scala:18)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:354)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:360)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:315)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:337)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:348)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:357)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:357)
        at dotty.tools.dotc.Run.compileSources(Run.scala:261)
        at dotty.tools.dotc.Run.compile(Run.scala:246)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
        at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
        at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:133)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$7(BloopHighLevelCompiler.scala:155)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:71)
        at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:70)
        at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$6(BloopHighLevelCompiler.scala:155)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
        at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81)
        at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
        at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
        at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions