Skip to content

Warn on bad extensions of effectively final aliases #22233

Closed
@som-snytt

Description

@som-snytt

Compiler version

3.6.2

Minimized code

//extension (s: java.lang.String) def length = 42 // warn
extension (s: String) def length = 42 // nowarn

Output

-- [E194] Potential Issue Warning: .../no-extension.scala:2:36 --
2 |extension (s: java.lang.String) def length = 42
  |                                    ^
  |Extension method length will never be selected
  |because String already has a member with the same name and compatible parameter types.

Expectation

The Scala alias should also warn, obviously.

Noticed at #17821.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions