diff options
author | Burak Emir <emir@epfl.ch> | 2006-02-14 17:14:24 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2006-02-14 17:14:24 +0000 |
commit | 9640cab2cc18236c36a3dde377e2986d211f345f (patch) | |
tree | 43be1af3ce182e7ed322aabab42c60987aaf0963 | |
parent | b499d07e91b473d37ee51748c53f7b9903b0833c (diff) | |
download | scala-9640cab2cc18236c36a3dde377e2986d211f345f.tar.gz scala-9640cab2cc18236c36a3dde377e2986d211f345f.tar.bz2 scala-9640cab2cc18236c36a3dde377e2986d211f345f.zip |
changed handling of MatchError, prints string now
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/CodeFactory.scala | 34 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternMatchers.scala | 6 |
2 files changed, 14 insertions, 26 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala index 870ae1dfe5..2f03283ed0 100644 --- a/src/compiler/scala/tools/nsc/matching/CodeFactory.scala +++ b/src/compiler/scala/tools/nsc/matching/CodeFactory.scala @@ -185,30 +185,8 @@ mixin class CodeFactory requires TransMatcher { } */ def Equals(left: Tree , right: Tree ): Tree = Apply(Select(left, nme.EQEQ), List(right)); -/* { var left = left1; - var right = right1; -*/ -/* - //Console.println("CodeFactory:: left.tpe =" + left.tpe + " right.tpe "+right.tpe+")"); - val ltype = left.tpe.widen; - var rtype = right.tpe.widen; - if (isSameType(ltype, rtype) - && (isSameType(ltype, definitions.CharClass.info) - || isSameType(ltype,definitions.ByteClass.info) - || isSameType(ltype,definitions.ShortClass.info))) - { - //Console.println("getcoerce"+getCoerceToInt(rtype)); - //Console.println("getcoerce.tpe"+getCoerceToInt(rtype).tpe); - right = Apply(Select(right, getCoerceToInt(rtype)), List()); - rtype = definitions.IntClass.info; - } - val eqsym = getEqEq(ltype, rtype); -*/ - //Console.println("eqsym "+eqsym); - //Console.println("eqsym.tpe "+eqsym.tpe); -// Apply(Select(left1, nme.EQEQ/*eqsym*/), List(right1)); -// } + //deprecated def ThrowMatchError(pos: Int, tpe: Type ) = atPos(pos) { Throw( @@ -218,6 +196,16 @@ mixin class CodeFactory requires TransMatcher { Literal(cunit.toString()), Literal(Position.line(cunit.source, pos)))))) } +//new + def ThrowMatchError(pos: Int, obj: Tree ) = + atPos(pos) { + Throw( + New( + TypeTree(definitions.MatchErrorClass.tpe), + List(List( + obj + )))) + } /* Apply( diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala index 38febba140..b364f9ce3e 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala @@ -189,7 +189,7 @@ mixin class PatternMatchers requires (TransMatcher with PatternNodes) extends An //Console.println("X"); val node = pConstrPat(tree.pos, tpe.tpe); env.newBoundVar( tree.symbol, - tpe.tpe /*scalac: tree.tpe */, + tpe.tpe, /*scalac: tree.tpe */ typed(Ident( node.casted ))); node; } @@ -663,7 +663,7 @@ mixin class PatternMatchers requires (TransMatcher with PatternNodes) extends An //print(); val ncases = numCases(root.and); - val matchError = ThrowMatchError(selector.pos, resultType); + 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) return defaultBody(root.and, matchError); @@ -753,7 +753,7 @@ mixin class PatternMatchers requires (TransMatcher with PatternNodes) extends An List( ValDef(root.symbol, selector), toTree(root.and), - ThrowMatchError(selector.pos, resultType)), + ThrowMatchError(selector.pos, Ident(root.symbol))), LabelDef(exit, List(result), Ident(result))) } |