Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
arthurp opened this issue Nov 7, 2020 · 1 comment · Fixed by #10226
Closed

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

arthurp opened this issue Nov 7, 2020 · 1 comment · Fixed by #10226
Assignees
Milestone

Comments

@arthurp
Copy link

arthurp commented Nov 7, 2020

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.

@griggt
Copy link
Contributor

griggt commented Nov 7, 2020

Regressed in 8c80c31 (0.22.0-RC1)

@smarter smarter self-assigned this Nov 7, 2020
smarter added a commit to dotty-staging/dotty that referenced this issue Nov 7, 2020
smarter added a commit to dotty-staging/dotty that referenced this issue Nov 7, 2020
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants