Skip to content

Type is simplified too much before being passed to an implicit macro #17544

Open
@neko-kai

Description

@neko-kai

Compiler version

3.3.0-RC6 and 3.2.2

Minimized code

// file:exampleMacro.scala

package example

import scala.quoted.*

case class X[T](x: String)

object X {
  inline given exampleMacro[T]: X[T] = ${ exampleMacroImpl[T] }

  def exampleMacroImpl[T: Type](using qctx: Quotes): Expr[X[T]] = {
    '{ X[T](${ Expr(Type.show[T]) }) }
  }
}
// file:example.scala

package example

trait TraitSuper
trait TraitSub extends TraitSuper

@main def main: Unit = {
  println(X.exampleMacro[TraitSuper & TraitSub].x) // outputs: verbatim type tree
  println(implicitly[X[TraitSuper & TraitSub]].x) // output: modified type tree
}

Output

example.TraitSuper & example.TraitSub
example.TraitSub

Expectation

The type received on the macro side differs when the macro is invoked implicitly versus when the macro is invoked explicitly – expected to receive the same type tree in both cases.

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