Skip to content

Scala.js optimizer crashes when using js.dynamicImport #17344

Closed
@lolgab

Description

@lolgab

Compiler version

3.3.1-RC1-bin-20230424-824295e-NIGHTLY

Minimized code

class Foo() {
  def foo() = 1
}
class Bar(foo: Foo) {
  def bar() = scalajs.js.dynamicImport(foo.foo())
}

object Main {
  def main(args: Array[String]): Unit = {
    val foo = new Foo()
    val bar = new Bar(foo)
    bar.bar()
  }
}

Output

Linker: Compute reachability: 13304 us
Linker: Assemble LinkedClasses: 716 us
Linker: 22690 us
Optimizer: Batch mode: true
Optimizer: Incremental part: 6120 us
Optimizer: Optimizing 203 methods.
1 targets failed
fullLinkJS org.scalajs.linker.frontend.optimizer.OptimizerCore$OptimizeException: The Scala.js optimizer crashed while optimizing static Bar$$anon$1.dynamicImport$;LBar;Ljava.lang.Object: java.util.NoSuchElementException: key not found: FieldID(ClassName<Bar$$anon$1>, FieldName<$outer>)
Methods attempted to inline:
* Bar$$anon$1.apply;Ljava.lang.Object

java.util.NoSuchElementException: key not found: FieldID(ClassName<Bar$$anon$1>, FieldName<$outer>)

Expectation

It links correctly when switching to Scala 2.13.10, so it should also using Scala 3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions