Skip to content

Adding scalajs-linker as a dependency introduces unexpected error #21560

Closed as not planned
@kincsescsaba

Description

@kincsescsaba

I ran the Scala 3 compiler (version: 3.5.0) successfully with the -scalajs option, sjsir files appear in the target directory as expected.

After this step, I wanted to create human-readable JavaScript. Therefore I added scalajs-linker as a dependency to the SBT project.

Running the first step again with the scalajs-linker being added, I unexpectedly get an error:

     while compiling: (inline)
        during phase: genSJSIR
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.0
            settings: -classpath "" -d (memory) -nowarn true -scalajs true -usejavacp true

An exception or error caused a run to abort: 'org.scalajs.ir.Types$ClassType org.scalajs.ir.Types$ClassType$.unapply(org.scalajs.ir.Types$ClassType)' 
java.lang.NoSuchMethodError: 'org.scalajs.ir.Types$ClassType org.scalajs.ir.Types$ClassType$.unapply(org.scalajs.ir.Types$ClassType)'
...

I assume the source to be compiled was OK, as sjsir files were generated.

Dependencies were set up with cross-version settings in SBT:

libraryDependencies ++= Seq(
      "org.scala-lang" %% "scala3-compiler" % scalaVersion.value,
      ("org.scala-js" %% "scalajs-library" % "1.16.0").withCrossVersion(CrossVersion.for3Use2_13),
      ("org.scala-js" %% "scalajs-linker" % "1.16.0").withCrossVersion(CrossVersion.for3Use2_13),
       ...
    )

The scalajs-library dependency did not introduce binary compatibility issues (Scala 2.13 and 3 should be binary compatible https://docs.scala-lang.org/overviews/core/binary-compatibility-of-scala-releases.html) while the linker (or an IR related dependency of it) did.

Looks like a nested case does not get an unapply method generated when it was compiled, this may cause the linker jar file to be binary incompatible, if there is no other circumstance that could cause this error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions