Skip to content

Can't quote fn arg defined in splice #11782

Closed
@japgolly

Description

@japgolly

Compiler version

3.0.0-RC1

Minimized code

  trait X[A] { def x(a: A): Boolean }

  def hmm[A](using Quotes, Type[A]): Expr[Unit] = {
    def sadFace(f: (Expr[A]) => Expr[Boolean]): Expr[X[A]] = '{
      new X[A] {
        override def x(a: A) = ${f('a)}
      }
    }
    '{()}
  }

Output

[error] 45 |        override def x(a: A) = ${f('a)}
[error]    |                                   ^^
[error]    |ambiguous implicit arguments: both parameter evidence$3 and parameter x$1 match type scala.quoted.Quotes

Expectation

It should compile.

The same quote/splice syntax is being used in docs here: https://dotty.epfl.ch/docs/reference/contextual/derivation-macro.html

         '{ eqSum((x: T, y: T) => ${eqSumBody('x, 'y)}) }

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