Skip to content

Unhelpful warning: Extension method f will never be selected from type <none> #22706

Closed
@OndrejSpanel

Description

@OndrejSpanel

Compiler version

3.7.0-RC1-bin-20250228-e592b37-NIGHTLY

Minimized code

A bit extended version of #22705

object Native {
  class O {
    def f: String = "F"
  }
  class M extends O
}

object Types {
  opaque type N = Native.O
  opaque type GS = Native.M

  type S = N | GS

  object S:
    def apply(): S = new N

  extension (s: S)
    def f: String = "S"
}

import Types.*

object Main {
  def main(args: Array[String]): Unit = {
    val v: S = S()
    println(v.f)
  }
}

Output

Extension method f will never be selected from type <none>
because <none> already has a member with the same name and compatible parameter types.
    def f: String = "S"

Expectation

The warning should not reference a type as <none>.

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions