Last active
August 29, 2015 13:59
-
-
Save mandubian/10476640 to your computer and use it in GitHub Desktop.
How to determine a Tree of type `Some[Int]` can be seen as weakTypeTag[Option[_]] in this macro?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I have a macro | |
def macmac[M[_], T] = macro macmacImpl | |
def macmacImpl[M[_], T: c.WeakTypeTag](c: Context) | |
(body: c.Expr[T]) | |
(implicit mw: c.WeakTypeTag[M[_]]): c.Expr[M[T]] | |
// somewhere in the macro, it's calling this function | |
def myFun[M[_], T](block: Tree)(mType: WeakTypeTag[M[_]], tType: WeakTypeTag[T]): Tree = { | |
... | |
val arg: Tree = // ... created a tree of type Some[Int] and I'm sure of this part | |
val stableRef = gen.mkAttributedStableRef(valDef.symbol).setType(arg.tpe).setPos(tree.pos) | |
... | |
println(stableRef.tpe weak_<:< mType.tpe) // => false ... WHY THAT???? | |
... | |
} | |
// Naturally I call it with something like | |
macmac[Option, Int](...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As this is just an extract of the code, it's not so easy for you to see exactly... sorry...
Here is what I can tell you:
and it prints: