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

Warn if a type parameter shadows a non-parameter #378

Merged
merged 2 commits into from
Jan 27, 2024
Merged

Conversation

b-studios
Copy link
Collaborator

@b-studios b-studios commented Jan 27, 2024

This tries to fix #368 by emitting a warning in case a type parameter shadows an outer type, which is not a type parameter (since this sometimes is desired and could lead to too many false negatives).

An example can be seen here:

effect Foo[A](x: A): A
interface Bar {
def op[B](b: B): Unit
}
def bar = new Bar {
def op[Int](n) = () // WARN shadows
}
def main(): Int =
try {
//...
0
} with Foo[Int] { // WARN shadows
(x: Int) => 12
}

@b-studios
Copy link
Collaborator Author

TBH while going through this code I was tempted to refactor Scope to be an enum. This code is older than Scala 3 and writing it in a functional style might be clearer.

@b-studios b-studios merged commit 3aa78e8 into master Jan 27, 2024
2 checks passed
@b-studios b-studios deleted the fix/issue368 branch January 27, 2024 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add warning when shadowing types
1 participant