Skip to content

Incorrect RefChecks in Scala2 mode #5831

Closed
@liufengyun

Description

@liufengyun

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions