Skip to content

Incorrect erasure for intersection type in Java method #12586

Closed
@tpolecat

Description

@tpolecat

Compiler version

3.0.0

Minimized code

Add dependency "org.testcontainers" % "testcontainers" % "1.15.2" and then try the following:

scala> new org.testcontainers.images.builder.ImageFromDockerfile().withFileFromClasspath("foo", "bar")                                                                                                                   
java.lang.NoSuchMethodError: 'org.testcontainers.images.builder.traits.BuildContextBuilderTrait org.testcontainers.images.builder.ImageFromDockerfile.withFileFromClasspath(java.lang.String, java.lang.String)'
  ... 38 elided

The method in question is defined here.

Scala 2.13 generates the following instruction:

      16: invokeinterface #45,  3           // InterfaceMethod org/testcontainers/images/builder/traits/ClasspathTrait.withFileFromClasspath:(Ljava/lang/String;Ljava/lang/String;)Lorg/testcontainers/images/builder/traits/ClasspathTrait;

Scala 3.0 generates the following, which differs in the return type.

      18: invokeinterface #34,  3           // InterfaceMethod org/testcontainers/images/builder/traits/ClasspathTrait.withFileFromClasspath:(Ljava/lang/String;Ljava/lang/String;)Lorg/testcontainers/images/builder/traits/BuildContextBuilderTrait;

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions