summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-27 07:55:55 +0000
committerPaul Phillips <paulp@improving.org>2011-01-27 07:55:55 +0000
commite40485618cea87366760628c3b264fd5c61790cf (patch)
treea60b39dbdf41ab34df00c1e80d5aa0867224139e
parentfcdc2267fe55074829c3a1c43c0bbdb403af64c0 (diff)
downloadscala-e40485618cea87366760628c3b264fd5c61790cf.tar.gz
scala-e40485618cea87366760628c3b264fd5c61790cf.tar.bz2
scala-e40485618cea87366760628c3b264fd5c61790cf.zip
Another naked assert is brought up on obscenity...
Another naked assert is brought up on obscenity charges. That second argument is not just a conversation piece, it can be used to communicate data! No review.
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index bdc8c32644..d232bee46d 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -56,29 +56,17 @@ abstract class TreeGen {
if (clazz.isEffectiveRoot) EmptyTree
else mkAttributedThis(clazz)
case SingleType(pre, sym) =>
- val qual = mkAttributedStableRef(pre, sym)
- qual.tpe match {
- case MethodType(List(), restpe) =>
- Apply(qual, List()) setType restpe
- case _ =>
- qual
- }
+ applyIfNoArgs(mkAttributedStableRef(pre, sym))
case TypeRef(pre, sym, args) =>
if (sym.isRoot) {
mkAttributedThis(sym)
} else if (sym.isModuleClass) {
- val qual = mkAttributedRef(pre, sym.sourceModule)
- qual.tpe match {
- case MethodType(List(), restpe) =>
- Apply(qual, List()) setType restpe
- case _ =>
- qual
- }
+ applyIfNoArgs(mkAttributedRef(pre, sym.sourceModule))
} else if (sym.isModule || sym.isClass) {
assert(phase.erasedTypes, tpe)
mkAttributedThis(sym)
} else if (sym.isType) {
- assert(termSym != NoSymbol)
+ assert(termSym != NoSymbol, tpe)
mkAttributedIdent(termSym) setType tpe
} else {
mkAttributedRef(pre, sym)
@@ -94,12 +82,19 @@ abstract class TreeGen {
// I am unclear whether this is reachable, but
// the following implementation looks logical -Lex
val firstStable = parents.find(_.isStable)
- assert(!firstStable.isEmpty)
+ assert(!firstStable.isEmpty, tpe)
mkAttributedQualifier(firstStable.get)
case _ =>
abort("bad qualifier: " + tpe)
}
+ /** If this is a reference to a method with an empty
+ * parameter list, wrap it in an apply.
+ */
+ private def applyIfNoArgs(qual: Tree) = qual.tpe match {
+ case MethodType(Nil, restpe) => Apply(qual, Nil) setType restpe
+ case _ => qual
+ }
/** Builds a reference to given symbol with given stable prefix. */
def mkAttributedRef(pre: Type, sym: Symbol): Tree = {