diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-28 13:04:38 -0700 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-28 13:04:38 -0700 |
commit | e46ceca8a0166a459cb336da83ae71afe69dc025 (patch) | |
tree | 51a52930865c6981210d2c92389fe80357d833b6 /src/compiler | |
parent | 8815637c0f0dddb4a044cd243e31890d535591e2 (diff) | |
parent | c395c926216b4356c82c606b76784a184a7f1d9b (diff) | |
download | scala-e46ceca8a0166a459cb336da83ae71afe69dc025.tar.gz scala-e46ceca8a0166a459cb336da83ae71afe69dc025.tar.bz2 scala-e46ceca8a0166a459cb336da83ae71afe69dc025.zip |
Merge pull request #1415 from scalamacros/is-value-type
a fork of isValueType and isNonValueType
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/reflect/reify/utils/Extractors.scala | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala index b7206eda0e..b60d15c1d4 100644 --- a/src/compiler/scala/reflect/reify/utils/Extractors.scala +++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala @@ -92,11 +92,18 @@ trait Extractors { Block(List(universeAlias, mirrorAlias), wrappee) } + // if we're reifying a MethodType, we can't use it as a type argument for TypeTag ctor + // http://groups.google.com/group/scala-internals/browse_thread/thread/2d7bb85bfcdb2e2 + private def mkTarg(tpe: Type): Tree = ( + if ((tpe eq null) || !isUseableAsTypeArg(tpe)) TypeTree(AnyTpe) + else TypeTree(tpe) + ) + object ReifiedTree { def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, rtree: Tree, tpe: Type, rtpe: Tree, concrete: Boolean): Tree = { val tagFactory = if (concrete) nme.TypeTag else nme.WeakTypeTag - val tagCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe))) - val exprCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), nme.Expr), nme.apply), List(TypeTree(tpe))) + val tagCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(mkTarg(tpe))) + val exprCtor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), nme.Expr), nme.apply), List(mkTarg(tpe))) val tagArgs = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe)) val unwrapped = Apply(Apply(exprCtor, List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TREECREATOR_PREFIX, symtab, rtree))), List(Apply(tagCtor, tagArgs))) mkWrapper(universe, mirror, unwrapped) @@ -123,7 +130,7 @@ trait Extractors { object ReifiedType { def apply(universe: Tree, mirror: Tree, symtab: SymbolTable, tpe: Type, rtpe: Tree, concrete: Boolean) = { val tagFactory = if (concrete) nme.TypeTag else nme.WeakTypeTag - val ctor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(TypeTree(tpe))) + val ctor = TypeApply(Select(Select(Ident(nme.UNIVERSE_SHORT), tagFactory), nme.apply), List(mkTarg(tpe))) val args = List(Ident(nme.MIRROR_SHORT), mkCreator(tpnme.REIFY_TYPECREATOR_PREFIX, symtab, rtpe)) val unwrapped = Apply(ctor, args) mkWrapper(universe, mirror, unwrapped) |