Scala 3 TypeRepr match on higher-kinded type

Viewed 274

How do I properly pattern match a TypeRepr on a higher-kinded type? Existentials successfully match for classes, but when I try with a type I get the compiler error unreducible application of higher-kinded type writetype.Foo to wildcard arguments

import scala.quoted.*

type Foo[X]
class Bar[X]

inline def writeType[T]: String = ${writeTypeImpl[T]}

def writeTypeImpl[T](using Type[T], Quotes): Expr[String] =
  import quotes.reflect.*
  val tpe = TypeRepr.of[T]
  val s = tpe.asType match
    //case '[Foo[?]] => "FooSuccess"
    case '[Bar[?]] => "BarSuccess"
    case _ => "Fail"

  Expr(s)
1 Answers
Related