Skip to content

Incorrect RefChecks in Scala2 mode #5831

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
liufengyun opened this issue Feb 1, 2019 · 1 comment
Closed

Incorrect RefChecks in Scala2 mode #5831

liufengyun opened this issue Feb 1, 2019 · 1 comment

Comments

@liufengyun
Copy link
Contributor

liufengyun commented Feb 1, 2019

The following code compiles in Scalac, but Dotty produces an error without message when compiled with -language:Scala2:

// dotc -d out -language:Scala2 examples/matcher.scala
trait Matchers { matchers =>
  private sealed trait Collected extends Product with Serializable
  def foo[T](collected: Collected, xs: scala.collection.GenTraversable[T]): Int  = 3
}
object Matchers extends Matchers

The problem is that RefChecks does not take into acount that Collected is visible in Matchers$ under Scala2 mode.

The missing error message is caused by the incorrect call getMessage instead of toMessage on TypeError.

https://github.com/lampepfl/dotty/blob/6bb20b33db43171d4b0ca4f7bfcbfbf0d73dcc8c/compiler/src/dotty/tools/dotc/typer/RefChecks.scala#L975-L987

@liufengyun
Copy link
Contributor Author

I've been playing this, it seems there is no easy fix without introducing complexity and bugs just for an incorrect behavior in Scala2.

Given that:

  1. Scala2 does the wrong thing
  2. There is a simple fix in source code

We close the issue, and the incompatibility is added to https://github.com/lampepfl/dotty/wiki/Known-incompatibilities-with-scalac .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant