Type check in macros should not yield an unchecked warning (caused by erasure) when the corresponding AbsTypeTag is in scope:
def test[A, B](a: A, b: B): A = macro test_impl[A,B]
def test_impl[A: c.AbsTypeTag, B](c: Context)(a: c.Expr[A], b: c.Expr[B]): c.Expr[A] = {
import c.universe._
reify {
b.splice match {
case bb: A => bb
case _ => a.splice
}
}
}
Leads to the following compiler warning:
[warn] /home/dk/macropolis/src/main/scala/macropolis/Equalizer.scala:16: abstract type A in type pattern A is unchecked since it is eliminated by erasure
[warn] case bb:A => bb
[warn]
Comment by Eugene [1]:
That's a limitation of the typecheck, and I invite you to submit a
bug about it. The thing is that the reifee (the body of the reify
call) is: 1) typechecked and, 2) only then reified. The typechecker
from the step 1 doesn't know anything about reification and, in
particular, doesn't know that T isn't just an abstract type, but is
going to be spliced later.
Type check in macros should not yield an unchecked warning (caused by erasure) when the corresponding AbsTypeTag is in scope:
Leads to the following compiler warning:
Comment by Eugene [1]:
That's a limitation of the typecheck, and I invite you to submit a bug about it. The thing is that the reifee (the body of the reify call) is: 1) typechecked and, 2) only then reified. The typechecker from the step 1 doesn't know anything about reification and, in particular, doesn't know that T isn't just an abstract type, but is going to be spliced later.
[1] https://groups.google.com/d/msg/scala-user/alYUId3YmuY/rr9WSuAGjwQJ