A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.scala-lang.org/scala3/reference/dropped-features/class-shadowing.html below:

Dropped: Class Shadowing

Edit this page on GitHub Dropped: Class Shadowing

Scala 2 so far allowed patterns like this:

class Base {
  class Ops { ... }
}

class Sub extends Base {
  class Ops { ... }
}

Scala 3 rejects this with the error message:

6 |      class Ops {  }
  |            ^
  |class Ops cannot have the same name as class Ops in class Base
  | -- class definitions cannot be overridden

The issue is that the two Ops classes look like one overrides the other, but classes in Scala 2 cannot be overridden. To keep things clean (and its internal operations consistent) the Scala 3 compiler forces you to rename the inner classes so that their names are different.

More details


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4