summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-04 00:06:52 +0000
committerPaul Phillips <paulp@improving.org>2010-11-04 00:06:52 +0000
commitde012b3a6d04f1e7a9fd6fecd403e0492f6ad7c1 (patch)
tree53bfa4fa1228515dd378f71037f1be594f57f08a
parentdb163e25eb606c4f1d23a5aa7b9c117a611daa0a (diff)
downloadscala-de012b3a6d04f1e7a9fd6fecd403e0492f6ad7c1.tar.gz
scala-de012b3a6d04f1e7a9fd6fecd403e0492f6ad7c1.tar.bz2
scala-de012b3a6d04f1e7a9fd6fecd403e0492f6ad7c1.zip
Some minor patmat/symbols cleanups, some of whi...
Some minor patmat/symbols cleanups, some of which I could swear I'd already checked in. No review.
-rw-r--r--src/compiler/scala/tools/nsc/matching/MatchSupport.scala3
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternBindings.scala9
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala10
3 files changed, 9 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala
index 2f50435db6..7cd8a27d3e 100644
--- a/src/compiler/scala/tools/nsc/matching/MatchSupport.scala
+++ b/src/compiler/scala/tools/nsc/matching/MatchSupport.scala
@@ -23,6 +23,9 @@ trait MatchSupport extends ast.TreeDSL { self: ParallelMatching =>
def impossible: Nothing = abort("this never happens")
+ def treeCollect[T](tree: Tree, pf: PartialFunction[Tree, T]): List[T] =
+ tree filter (pf isDefinedAt _) map (x => pf(x))
+
object Types {
import definitions._
implicit def enrichType(x: Type): RichType = new RichType(x)
diff --git a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala
index 83fd3a9608..61ab4f31d1 100644
--- a/src/compiler/scala/tools/nsc/matching/PatternBindings.scala
+++ b/src/compiler/scala/tools/nsc/matching/PatternBindings.scala
@@ -119,17 +119,10 @@ trait PatternBindings extends ast.TreeDSL
case _ => Nil
}
private def deepstrip(t: Tree): List[Symbol] =
- t filter { case _: Bind => true ; case _ => false } map (_.symbol)
+ treeCollect(t, { case x: Bind => x.symbol })
}
case class Binding(pvar: Symbol, tvar: Symbol) {
- // see bug #1843 for the consequences of not setting info.
- // there is surely a better way to do this, especially since
- // this looks to be the only usage of containsTp anywhere
- // in the compiler, but it suffices for now.
- if (tvar.info containsTp WildcardType)
- tvar setInfo pvar.info
-
override def toString() = pp(pvar -> tvar)
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 7ffc168c6e..9bf59d0bfc 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -376,12 +376,12 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
final def isPackageObject = isModule && name == nme.PACKAGEkw && owner.isPackageClass
final def isPackageObjectClass = isModuleClass && name.toTermName == nme.PACKAGEkw && owner.isPackageClass
final def definedInPackage = owner.isPackageClass || owner.isPackageObjectClass
- final def isPredefModule = isModule && name == nme.Predef && owner.isScalaPackageClass // not printed as a prefix
+ final def isPredefModule = this == PredefModule // not printed as a prefix
final def isJavaInterface = isJavaDefined && isTrait
- final def isScalaPackage = isPackage && name == nme.scala_ && owner.isRoot || // not printed as a prefix
- isPackageObject && owner.isScalaPackageClass
- final def isScalaPackageClass: Boolean = isPackageClass && owner.isRoot && name == nme.scala_.toTypeName ||
- isPackageObjectClass && owner.isScalaPackageClass // not printed as a prefix
+
+ // not printed as prefixes
+ final def isScalaPackage = (this == ScalaPackage) || (isPackageObject && owner == ScalaPackageClass)
+ final def isScalaPackageClass = (this == ScalaPackageClass) || (isPackageObjectClass && owner == ScalaPackageClass)
/** Is symbol a monomorphic type?
* assumption: if a type starts out as monomorphic, it will not acquire