Skip to content
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

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

Closed
schuetzcarl opened this issue May 30, 2023 · 0 comments
Closed

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

schuetzcarl opened this issue May 30, 2023 · 0 comments
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:enhancement

Comments

@schuetzcarl
Copy link
Contributor

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
@schuetzcarl schuetzcarl added the stat:needs triage Every issue needs to have an "area" and "itype" label label May 30, 2023
@jchyb jchyb added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 30, 2023
schuetzcarl added a commit to schuetzcarl/dotty that referenced this issue May 30, 2023
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : scala#17612 and scala#17613
schuetzcarl added a commit to schuetzcarl/dotty that referenced this issue May 30, 2023
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : scala#17612 and scala#17613
szymon-rd added a commit that referenced this issue Sep 29, 2023
Implemented two additional lint warnings for my bachelor project
supervised by @anatoliykmetyuk.

Most of the work has been done in a new `MiniPhase` class called
`CheckShadowing` and running in the same mega phase as the
`CheckUnused.PostTyper` mini phase.

They respectively warn about :
- A private field or a class parameter that shadows a super-class field.
- A type parameter that shadows a type already defined in the scope.

Some examples can be seen in #17612 and #17613.
WojciechMazur pushed a commit that referenced this issue Jun 19, 2024
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : #17612 and #17613

[Cherry-picked e5fd477]
WojciechMazur pushed a commit that referenced this issue Jun 19, 2024
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : #17612 and #17613

[Cherry-picked e5fd477]
WojciechMazur pushed a commit that referenced this issue Jun 19, 2024
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : #17612 and #17613

[Cherry-picked e5fd477]
WojciechMazur pushed a commit that referenced this issue Jun 19, 2024
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : #17612 and #17613

[Cherry-picked e5fd477]
WojciechMazur pushed a commit that referenced this issue Jun 19, 2024
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : #17612 and #17613

[Cherry-picked e5fd477]
WojciechMazur pushed a commit that referenced this issue Jun 20, 2024
Respectively warn about :
- a private field or a class parameter that shadows a superclass field
- a local type parameter that shadows a type already in the scope

Fixes : #17612 and #17613

[Cherry-picked e5fd477]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:enhancement
Projects
None yet
Development

No branches or pull requests

2 participants