Skip to content

Type check in macros should not yield an unchecked warning when the corresponding AbsTypeTag is in scope #6531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
scabug opened this issue Oct 17, 2012 · 1 comment

Comments

@scabug
Copy link

scabug commented Oct 17, 2012

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.

[1] https://groups.google.com/d/msg/scala-user/alYUId3YmuY/rr9WSuAGjwQJ

@scabug
Copy link
Author

scabug commented Oct 17, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6531?orig=1
Reporter: daniel kroeni (dk)
Affected Versions: 2.10.0-M7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants