summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Shabalin <denys.shabalin@typesafe.com>2014-02-07 14:43:01 +0100
committerDenys Shabalin <denys.shabalin@typesafe.com>2014-02-07 14:43:01 +0100
commita98eee51760c4961a5419747d2828d9765a9754b (patch)
tree44c060566ff4652db5b25f89ef67022d668b2767
parent1e5654c8bd10a3649ccc97c42a7949b179480073 (diff)
downloadscala-a98eee51760c4961a5419747d2828d9765a9754b.tar.gz
scala-a98eee51760c4961a5419747d2828d9765a9754b.tar.bz2
scala-a98eee51760c4961a5419747d2828d9765a9754b.zip
Better comment for SyntacticEmptyTypeTree
-rw-r--r--src/reflect/scala/reflect/internal/BuildUtils.scala9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/reflect/scala/reflect/internal/BuildUtils.scala b/src/reflect/scala/reflect/internal/BuildUtils.scala
index 4f4d7df793..458c10e69b 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