Skip to content

Inference de-aliasses types in macros #9421

Open
@nicolasstucki

Description

@nicolasstucki

Minimized example

import scala.quoted._

def myMacroImpl[T](using tp: Type[T])(using QuoteContext) = {
  val x = Expr(tp.show)
  '{ new TPrint[T]($x) }
}

class TPrint[T](override val toString: String)

inline def default[T]: TPrint[T] = ${ myMacroImpl[T] }
object Test extends App {

  type X = scala.Int with scala.Predef.String{}

  val s1: TPrint[X] = default[X]
  val s2: TPrint[X] = default

  println(s1)
  println(s2)

}

Output

Test.X
scala.Int & scala.Predef.String

Expectation

Both should be X

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