From a98eee51760c4961a5419747d2828d9765a9754b Mon Sep 17 00:00:00 2001 From: Denys Shabalin Date: Fri, 7 Feb 2014 14:43:01 +0100 Subject: [PATCH] Better comment for SyntacticEmptyTypeTree --- src/reflect/scala/reflect/internal/BuildUtils.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala index 4f4d7df793ea..458c10e69b3e 100644 --- a/src/reflect/scala/reflect/internal/BuildUtils.scala +++ b/src/reflect/scala/reflect/internal/BuildUtils.scala @@ -537,9 +537,12 @@ trait BuildUtils { self: SymbolTable => def unapply(tree: Tree): Option[Tree] = gen.Filter.unapply(tree) } - // TypeTree without original is used to signal that no type was provided - // by the user and compiler should infer it instead. (Note: EmptyTree is - // not appropriate in such role, it's only used for terms, not types.) + // If a tree in type position isn't provided by the user (e.g. `tpt` fields of + // `ValDef` and `DefDef`, function params etc), then it's going to be parsed as + // TypeTree with empty original and empty tpe. This extractor matches such trees + // so that one can write q"val x = 2" to match typecheck(q"val x = 2"). Note that + // TypeTree() is the only possible representation for empty trees in type positions. + // We used to sometimes receive EmptyTree in such cases, but not anymore. object SyntacticEmptyTypeTree extends SyntacticEmptyTypeTreeExtractor { def apply(): TypeTree = self.TypeTree() def unapply(tt: TypeTree): Boolean = tt.original == null || tt.original.isEmpty