Skip to content

From tasty compilation fails when referencing methods missing from the JDK #16709

Open
@WojciechMazur

Description

@WojciechMazur

It's a very specific issue, targeting mostly Scala Native and its the implementation of the Java standard library.
All usages of custom methods defined in Scala Native javalib for which we try to generate documentation, and which are missing from the JDK are failing to compile.
Setting custom java-boot-classpath/boot-classpath/classpath pointing only to outputs of javalib compilation seems not to give any effects. For some reason, it seems that scaldoc seems to ignore our custom classpath or injects it's own JDK entries.

Compiler version

Every Scala 3 version

Minimized code

// BigInteger.scala
package java.math

// uses constructor existing in  JDK
class BigInteger (private var signum: Int, private var magnitude: Array[Byte]) {
  // Does not exist in the JDK
  private[math] def this(sign: Int, value: Int) = 
    this(sign, Array(value.toByte))
}
// main.scala
package java.math

@main def Test = {
  val x = BigInteger(1, Array(0: Byte)) // ok, uses method existing in JDK
  val y = new BigInteger(1, 0) // fails, uses custom method
  println(x == y) 
}

Create doc using : scala-cli doc Test.scala BigInteger.scala (Order of files does matter)

Output

-- Error: Test.scala:5:14 ------------------------------------------------------
5 |  val y = new BigInteger(1, 0)
  |              ^^^^^^^^^^^^^^^
  |undefined: new java.math.BigInteger # -1: TermRef(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class java)),object math),BigInteger),<init>) at readTasty
1 error found

Expectation

Should respect custom classpath and allow to compile

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