Skip to content

Protected method not ignored when searching for extension method #21935

Open
@david04

Description

@david04

Compiler version

3.5.2

Minimized code

class C
object Implicits {
  implicit class RichC1(c: C) {
    // Please notice the protected:
    protected def m(): Unit = println("foo")
  }
  implicit class RichC2(c: C) {
    def m(): Unit = println("bar")
  }
}
object Sample {
  import Implicits._
  val c = new C
  c.m()
}

Output

Found:    (Playground.Sample.c : Playground.C)
Required: ?{ m: ? }
Note that implicit extension methods cannot be applied because they are ambiguous;
both method RichC1 in object Implicits and method RichC2 in object Implicits provide an extension method `m` on (Playground.Sample.c : Playground.C)

Expectation

should compile

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions