Skip to content

Implicit class without arguments #2464

Closed
@nicolasstucki

Description

@nicolasstucki
object Foo {
  object Bar
  implicit class Bar
}

fails with

-- Error: tests/run/phantom-implicit-class.scala:3:2 ---------------------------
3 |  object Bar
  |  ^
  |  Foo.Bar is not stable
-- Error: tests/run/phantom-implicit-class.scala:3:9 ---------------------------
3 |  object Bar
  |         ^
  |         object Bar is already defined as method Bar: ()Foo.Bar

two errors found

the signature of the lazy val of the module object Bar and the signature of desugared implicit method of implicit class Bar are the same and they have the same name.

The issues are:

  • The error message is not helpful unless you know about the desugaring and the signature internals.
  • Using implicit class on phantoms generates these kinds of ambiguities because the parameter will be erased.

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