Skip to content

Scala 3 macro cannot match abstract types #16782

Open
@Atry

Description

@Atry

Compiler version

3.2.2

Minimized code

import scala.quoted.*

given staging.Compiler = staging.Compiler.make(getClass.getClassLoader)

def matchIArray = staging.run {
  Type.of[IArray[Int]] match
    case '[IArray[t]] =>
      '{"IArray"}
    case _ =>
      '{"not IArray"}
  end match
}
println(matchIArray)

def matchArray = staging.run {
  Type.of[Array[Int]] match
    case '[Array[t]] =>
      '{"Array"}
    case _ =>
      '{"not Array"}
  end match
}
println(matchArray)

https://scastie.scala-lang.org/rDUMGIiBQ5Km5vxE7TEl1Q

Output

not IArray
Array

Expectation

IArray
Array

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