Skip to content

Dotty does not recognize subtyping relationships with Java raw types #10225

Closed
@arthurp

Description

@arthurp

Dotty appears not to correctly handle Java raw types that were handled by Scala 2.13.
I suspect this is caused by Dotty failing to see that XYChart is a subtype of the raw type Chart.
The following code compiles in Scala 2.13 and not in Dotty.

Minimized code

sbt:

libraryDependencies += "org.knowm.xchart" % "xchart" % "3.6.5"

scala:

import org.knowm.xchart.{XYChartBuilder, SwingWrapper}
object Main {
  def main(args: Array[String]): Unit = {
    val chart = new XYChartBuilder().build()
    new SwingWrapper(chart).displayChart()
  }
}

Output

In Dotty the error is:

None of the overloaded alternatives of constructor SwingWrapper in class SwingWrapper with types
 [T <: org.knowm.xchart.internal.chartpart.Chart]
  (x$0: java.util.List[T], x$1: Int, x$2: Int): org.knowm.xchart.SwingWrapper[T]
 [T <: org.knowm.xchart.internal.chartpart.Chart]
  (x$0: java.util.List[T]): org.knowm.xchart.SwingWrapper[T]
 [T <: org.knowm.xchart.internal.chartpart.Chart]
  (x$0: T): org.knowm.xchart.SwingWrapper[T]
match arguments ((chart : org.knowm.xchart.XYChart))

Expectation

No type error. Just like Scala 2.13.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions