Skip to content

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

Closed
@schuetzcarl

Description

@schuetzcarl

In the scope of my Bachelor Project supervised by @anatoliykmetyuk,
I would like 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions