Open
Description
Compiler version
3.3.1-RC1-bin-20230216-2507577-NIGHTLY
Minimized code
import scala.quoted.*
inline def test = ${ testImpl }
def testImpl(using Quotes) =
import quotes.reflect.*
val tree = TypeTree.of(using TypeBounds.empty.asType)
tree match
case _: Inferred => println("Inferred")
case _ =>
tree match
case _: TypeTree => println("TypeTree")
case _ =>
tree match
case _: TypeBoundsTree => println("TypeBoundsTree")
case _ =>
'{ () }
Output
When expanding, the macro prints:
TypeTree
TypeBoundsTree
Expectation
According to the documentation, a tree should not be both a TypeTree
and TypeBoundsTree
since none of them is a subtype of the other. When mapping over such a tree, Quotes#TreeMap
runs into an exception.
I suppose, the tree should be either (1) an Inferred
(which it is currently not), or (2) a TypeBoundsTree
but not a TypeTree
or (3) TypeBoundsTree
should be a subtype of TypeTree
(and be handled accordingly by TreeMap
).