diff options
author | Burak Emir <emir@epfl.ch> | 2007-01-14 01:33:08 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-01-14 01:33:08 +0000 |
commit | f3cf0544326e246cd6ecd1632ad43facc437e9d2 (patch) | |
tree | 2e4183b4a02512e188de0b8b0a6cff99a580d8c7 | |
parent | 003f7e2b70c4fd1945c0cc790aaaca542a529652 (diff) | |
download | scala-f3cf0544326e246cd6ecd1632ad43facc437e9d2.tar.gz scala-f3cf0544326e246cd6ecd1632ad43facc437e9d2.tar.bz2 scala-f3cf0544326e246cd6ecd1632ad43facc437e9d2.zip |
lib
Seq.scala: fixed unapply method
nsc
Trees.scala: Transformer is homomorphism for UnApply
ExplOuter: removed System.exit for debug (oops, this annoys Eclipse users)
TransM: case UnApply for isRegularPattern
GenICode: error msg gives compilation unit, too
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/TransMatcher.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala | 1 | ||||
-rw-r--r-- | src/library/scala/Seq.scala | 4 | ||||
-rw-r--r-- | test/pending/pos/unapplyContexts2.scala | 11 |
6 files changed, 17 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 2ca8fc057d..8f21650b13 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -1113,7 +1113,7 @@ trait Trees requires Global { case Bind(name, body) => copy.Bind(tree, name, transform(body)) case UnApply(fun, args) => - copy.UnApply(tree, fun, args) + copy.UnApply(tree, fun, transformTrees(args)) // bq: see test/.../unapplyContexts2.scala case ArrayValue(elemtpt, trees) => copy.ArrayValue(tree, transform(elemtpt), transformTrees(trees)) case Function(vparams, body) => diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index e6c3c94b4d..b2208a89cc 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -787,7 +787,7 @@ abstract class GenICode extends SubComponent { case This(qual) => assert(tree.symbol == ctx.clazz.symbol || tree.symbol.isModuleClass, "Trying to access the this of another class: " + - "tree.symbol = " + tree.symbol + ", ctx.clazz.symbol = " + ctx.clazz.symbol) + "tree.symbol = " + tree.symbol + ", ctx.clazz.symbol = " + ctx.clazz.symbol + " compilation unit:"+unit) if (tree.symbol.isModuleClass && tree.symbol != ctx.clazz.symbol) { if (settings.debug.value) log("LOAD_MODULE from 'This': " + tree.symbol); diff --git a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala index cdd4c5fee2..bf4ace47ea 100644 --- a/src/compiler/scala/tools/nsc/matching/TransMatcher.scala +++ b/src/compiler/scala/tools/nsc/matching/TransMatcher.scala @@ -129,6 +129,8 @@ with PatternMatchers */ { case Literal(_) => false case Select(_, _) => false case Typed(_, _) => false + case UnApply(_,trees) => + trees exists { isRegularPattern } } protected def isDefault(p: Tree): Boolean = p match { diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index 97c31bed53..e225c70a4f 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -510,7 +510,6 @@ abstract class ExplicitOuter extends InfoTransform with TransMatcher with Patter //treeBrowser.browse(Seq.single(unit).elements) Console.println("[died while typechecking the translated pattern match:]") Console.println(t_untyped) - System.exit(-1) null } case _ => diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala index 2b20b978cb..6ff68ee6f5 100644 --- a/src/library/scala/Seq.scala +++ b/src/library/scala/Seq.scala @@ -23,8 +23,8 @@ object Seq { def elements = Iterator.empty } - def unapplySeq[A](x:Any): Option[Tuple1[Seq[A]]] = - if(x.isInstanceOf[Seq[A]]) Some(Tuple1(x.asInstanceOf[Seq[A]])) else None + def unapplySeq[A](x:Any): Option[Seq[A]] = + if(x.isInstanceOf[Seq[A]]) Some(x.asInstanceOf[Seq[A]]) else None /** builds a singleton sequence * @author buraq diff --git a/test/pending/pos/unapplyContexts2.scala b/test/pending/pos/unapplyContexts2.scala new file mode 100644 index 0000000000..fcf1e2ff62 --- /dev/null +++ b/test/pending/pos/unapplyContexts2.scala @@ -0,0 +1,11 @@ +trait Analyzer { + val WILDCARD = "23" +} + +trait Contexts2 requires Analyzer { + class Context { + def collect(sels: List[String]): List[String] = sels match { + case List(WILDCARD) => val dummy = WILDCARD; Nil + } + } +} |