Skip to content

Don't warn on private proxy extension idiom #24066

@som-snytt

Description

@som-snytt

Compiler version

3.8

Minimized code

class Foo(val someField: Int)

extension (foo: Foo)
  def someField = foo.someField // warns even if private
  def bar1 = 1 + someField
  def bar2 = 2 + someField
  def bar3 = 3 + someField

#17543 (comment)

Output

5 |  private def someField = foo.someField
  |              ^
  |Extension method someField will never be selected from type Foo
  |because Foo already has a member with the same name and compatible parameter types.

Expectation

No warning because it is false. It's never too late to push back against false claims by tools and politicians.

The method is already known to be used under -Wunused. This warning could be under the same flag.

Note that the user might want an unusable extension because it is usable under an older JVM or other dependency. It might be nicer to make the warning "opt-in".

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions