Skip to content

Extension method in scope not found #9185

@FabioPinheiro

Description

@FabioPinheiro

Minimized code

On the REPL:

trait A[F[_]] {}
object A {
  def [A](x: A).pure: List[A] = List(x)
  val a = "ola".pure[List]
}

Output

4 |  val a = "ola".pure[List]
  |          ^^^^^^^^^^
  |value pure is not a member of String, but could be made available as an extension method.
  |
  |The following import might fix the problem:
  |
  |  import A.pure
  |

Expectation

I would expect it to compile.

Also if we have a package object like:

package object p {
  trait A[F[_]] {}
  object A {
    def [A](x: A).pure: List[A] = List(x)
    val a = "ola".pure[List]
  }
}

The error has a double suggestion.
I don't expect to see the second suggestion.
Furthermore, the suggestion with reserved keywords should have those words on backticks.

|    val a = "ola".pure[List]
|            ^^^^^^^^^^
|value pure is not a member of String, but could be made available as an extension method.
|
|One of the following imports might fix the problem:
|
|  import p.A.pure
|  import p.package.A.pure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions