Closed
Description
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.