Skip to content

New linter option : -Xlint:private-shadow #17612

Closed
@schuetzcarl

Description

@schuetzcarl

For the scope of my Bachelor Project supervised by @anatoliykmetyuk,
we planned to add for dotty an equivalent lint warning as the -Xlint:private-shadow of Scala 2.

It would warn about a private field or a class parameter that shadows a superclass field.

Here is a more concrete example from the Scala 2 issue ( scala/bug#4762 ) :

class Base(var x : Int):
	def increment() =
		x = x + 1

class Derived(x : Int) extends Base(x):
	override def toString = 
		x.toString

val derived = new Derived(1)
println(derived.toString)     // yields '1', as expected
derived.increment()
println(derived.toString)     // still '1', probably unexpected

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcitype:enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions