Skip to content

Correctly deal with Java/Scala impedence mismatch between Object/Any when using -Ypickle-write-java #12512

Closed
scala/scala
#9826
@retronym

Description

@retronym

The specific case that I believe is caused by this is:

package demo;

public class C {
  public static void ol(scala.Equals o) {} // Equals extends AnyVal
  public static void ol(Object o) {}
}
package demo
class Client {
  C.ol(Option(""))
}
$ for V in 2.12.15 2.13.6; do echo $V; scalac --scala-version $V -d /tmp -Ypickle-java -Ypickle-write /tmp/c.jar /tmp/C.java && scalac --scala-version $V -cp /tmp/c.jar /tmp/Client.scala; done
2.12.15
2.13.6
/tmp/Client.scala:3: error: ambiguous reference to overloaded definition,
both method ol in class C of type (o: Object): Unit
and  method ol in class C of type (o: Equals): Unit
match argument types (Option[String])
  C.ol(Option(""))
    ^
1 error

The relevant changes in 2.13 were:

scala/scala#7966
scala/scala#8049

-Ypickle-write is part of the infrastructure to support build pipelining. It writes a .sig file for .java source file that has its API typechecked by the Scala compiler. This can be uses on the classpath of downstream Scala compilation, instead of .class files.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions