summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-09-27 16:12:50 -0700
committerEugene Burmako <xeno.by@gmail.com>2012-09-28 14:22:05 +0200
commitb5b614444cefe84861b06a09fbaf10d100556556 (patch)
tree1b7b0e8f8410daa2cd41b76257d09e97ad4a0958 /src/compiler
parenta6b81ac12a45866e97d30133c12dee775b93ea39 (diff)
downloadscala-b5b614444cefe84861b06a09fbaf10d100556556.tar.gz
scala-b5b614444cefe84861b06a09fbaf10d100556556.tar.bz2
scala-b5b614444cefe84861b06a09fbaf10d100556556.zip
Implementations of isValueType and isNonValueType.
Restrictions regarding how non-value types can be used have generally not been enforced explicitly, depending instead on the fact that the compiler wouldn't attempt to use them in strange ways like offering a method type as a type argument. Since users can now create most types from scratch, it has become important to enforce the restrictions in a more direct fashion. This was a lot harder than it probably should have been because there are so many types which go unmentioned by the specification. Hopefully a useful exercise in any case.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/reify/utils/Extractors.scala13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/compiler/scala/reflect/reify/utils/Extractors.scala b/src/compiler/scala/reflect/reify/utils/Extractors.scala
index 523520749b..b60d15c1d4 100644
--- a/src/compiler/scala/reflect/reify/utils/Extractors.scala
+++ b/src/compiler/scala/reflect/reify/utils/Extractors.scala
@@ -92,13 +92,12 @@ trait Extractors {
Block(List(universeAlias, mirrorAlias), wrappee)
}
- private def mkTarg(tpe: Type): Tree = {
- // 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
- val guineaPig = Apply(TypeApply(Select(Select(gen.mkRuntimeUniverseRef, nme.TypeTag), nme.apply), List(TypeTree(tpe))), List(Literal(Constant(null)), Literal(Constant(null))))
- val isGoodTpe = typer.silent(_.typed(guineaPig)) match { case analyzer.SilentResultValue(_) => true; case _ => false }
- TypeTree(if (isGoodTpe) tpe else AnyTpe)
- }
+ // 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 = {