Skip to content

Misleading error message for extension methods with implicits #6762

Closed
@anatoliykmetyuk

Description

@anatoliykmetyuk

minimized code

import scala.quoted._
import delegate scala.quoted._

type G[X]
case class Foo[T](x: T)
def f(word: String): Expr[Foo[G[String]]] = '{Foo(${word.toExpr})}

expectation

An error message saying that the type of '{Foo(${word.toExpr})} is incorrect: it is Expr[Foo[String]] whereas Expr[Foo[G[String]]] is expected. Instead, the error message is as follows:

[error] -- [E008] Member Not Found Error: /Users/anatolii/Projects/dotty/playground/macros/src/main/scala/playground/macros.scala:45:59
[error] 45 |  def f(word: String): Expr[Foo[G[String]]] = '{Foo(${word.toExpr})}
[error]    |                                                      ^^^^^^^^^^^
[error]    |      value toExpr is not a member of String.
[error]    |      An extension method was tried, but could not be fully constructed:
[error]    |
[error]    |          quoted.ExprOps.toExpr[T](word)
[error] one error found

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