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 universal extensions on opaque type #22232

Open
som-snytt opened this issue Dec 18, 2024 · 0 comments
Open

Warn universal extensions on opaque type #22232

som-snytt opened this issue Dec 18, 2024 · 0 comments
Labels
area:linting Linting warnings enabled with -W or -Xlint area:opaque-types itype:bug

Comments

@som-snytt
Copy link
Contributor

Compiler version

3.6.2

Minimized code

class C
object C:
  extension (c: C) def equals(that: Any): Boolean = false // warn

object X:
  class C
  opaque type D <: C = C
  object D:
    extension (d: D) def equals(that: Any): Boolean = false // nowarn

Output

-- [E194] Potential Issue Warning: .../no-extension.scala:12:23 -
12 |  extension (c: C) def equals(that: Any): Boolean = false
   |                       ^
   |Extension method equals will never be selected
   |because C already has a member with the same name and compatible parameter types.

Expectation

Complain about defining extension methods which can't be invoked because they are universally available.

The loophole for opaque types is too wide.

Noticed at #17821.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:linting Linting warnings enabled with -W or -Xlint and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint area:opaque-types itype:bug
Projects
None yet
Development

No branches or pull requests

2 participants