diff options
author | Burak Emir <emir@epfl.ch> | 2007-02-06 17:34:45 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2007-02-06 17:34:45 +0000 |
commit | e8df51ba079ea8faf40dfb0e0fa3c395f9efb4f6 (patch) | |
tree | 1cf9d3ed054524f1e0c608a486087e728c4a36c3 /src | |
parent | 31365c2ab0eaaaf47053f10bace58f614e54e6c8 (diff) | |
download | scala-e8df51ba079ea8faf40dfb0e0fa3c395f9efb4f6.tar.gz scala-e8df51ba079ea8faf40dfb0e0fa3c395f9efb4f6.tar.bz2 scala-e8df51ba079ea8faf40dfb0e0fa3c395f9efb4f6.zip |
clean up, unapply disables any form of exhausti...
clean up, unapply disables any form of exhaustivity checking
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternMatchers.scala | 22 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternNodes.scala | 9 |
2 files changed, 14 insertions, 17 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 0cc4145d0a..3b4a88e63c 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -435,6 +435,7 @@ trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes) { node case t @ UnApply(fn, args) => + doCheckExhaustive = false // just seeing unapply pattern disables exhaustiveness check for whole match pUnapplyPat(tree.pos, fn) case t @ Apply(fn, args) => // pattern with args @@ -692,8 +693,7 @@ print() } else { //Console.println(" enter: using old header for casted = "+casted) // DBG // find most recent header - while (curHeader.next ne null) - curHeader = curHeader.next + curHeader = curHeader.findLastSection // create node var patNode = patternNode(pat, curHeader, env) var next: PatternNode = curHeader @@ -886,17 +886,6 @@ print() if (null == next) 1 else (next.length() + 1) } - protected def numCases(patNode1: PatternNode): Int = { - var patNode = patNode1 - var n = 0 - while (({patNode = patNode.or; patNode}) ne null) - patNode match { - case DefaultPat() => ; - case _ => n = n + 1 - } - n - } - protected def defaultBody(patNode1: PatternNode, otherwise: Tree ): Tree = { patNode1.asInstanceOf[Header].forEachSection { case h:Header => h.forEachBranch { @@ -921,7 +910,12 @@ print() } //print(); - val ncases = numCases(root.and) + var ncases = 0 + root.and.asInstanceOf[Header].forEachBranch { + case DefaultPat() => ; + case _ => ncases = ncases + 1 + } + val matchError = ThrowMatchError(selector.pos, Ident(root.symbol)) // without a case, we return a match error if there is no default case if (ncases == 0) diff --git a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala index 74698ac05b..cd0d5da3d8 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala @@ -298,13 +298,16 @@ trait PatternNodes requires transform.ExplicitOuter { var next: Header = next1 def findLast: PatternNode = { - var h: Header = this; - while(h.next != null) { h = h.next } - var g: PatternNode = h + var g: PatternNode = findLastSection while(g.or != null) { g = g.or } g } + def findLastSection: Header = { + var h: Header = this; + while(h.next != null) { h = h.next } + h + } var isSubHeader = false; // returns true if this header node has a catch all case |