Skip to content

methods available via implicit conversions should not include private methods #2066

Closed
@smarter

Description

@smarter
class Foo

object Test {
  implicit class One(x: Foo) {
    def meth: Unit = {}
  }

  implicit class Two(x: Foo) {
    private def meth: Unit = {}
  }

  def test(foo: Foo): Unit = {
    foo.meth
  }
}
-- [E007] Type Mismatch Error: try/privimpl.scala ------------------------------
13 |    foo.meth
   |    ^^^
   |found:    Foo(foo)
   |required: ?{ meth: ? }
   |
   |
   |Note that implicit conversions cannot be applied because they are ambiguous;
   | both method Two in object Test and method One in object Test convert from Foo(foo) to ?{ meth: Unit }

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