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 · 1 comment · May be fixed by #22502
Open

Warn universal extensions on opaque type #22232

som-snytt opened this issue Dec 18, 2024 · 1 comment · May be fixed by #22502
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint area:opaque-types itype:bug Spree Suitable for a future Spree

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
@mbovel mbovel added the Spree Suitable for a future Spree label Jan 12, 2025
@hamzaremmal hamzaremmal self-assigned this Feb 3, 2025
@mbovel
Copy link
Member

mbovel commented Feb 3, 2025

This issue was picked for tonight's Scala 3 Compiler Issue Spree. @hamzaremmal, @julian-a-avar-c and @nmcb will be working on it.

@rochala rochala linked a pull request Feb 3, 2025 that will close this issue
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 Spree Suitable for a future Spree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants