Quoted type pattern for '[Map[k, v]]
doesn't match when k
is an OrType
#21634
Labels
'[Map[k, v]]
doesn't match when k
is an OrType
#21634
Compiler version
3.5.1
Minimized code
A simple macro that has a quoted type pattern for a
'Map[k, v]
:Macro.scala:
Output
Expectation
Notes
Maybe this is not a bug, maybe it is a limitation or I'm thinking wrong, but for me it is not entirely clear why it depends on the key type whether I can match it. I asked in metaprogramming on discord and nobody seemed to know either, so here we are.
Also, thanks for your fantastic work on scala <3
Workaround
If somebody finds this ticket, whether it is a bug or not, and needs a quick workaround: Match on the
TypeRepr
:Now you have both
k
andv
matched and it works even ifk
is anOrType
, which you can then deconstruct furtherThe text was updated successfully, but these errors were encountered: