diff options
author | Martin Odersky <odersky@gmail.com> | 2005-12-01 14:29:55 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-12-01 14:29:55 +0000 |
commit | 09e5446bd38a91f097b19549e5d7f1342b6bbfc4 (patch) | |
tree | e16e31161f9b1fa2e5659068e014a4c70ecdd3f8 | |
parent | 0a8b8f9b903512e25caf16fef1f732d9478d9170 (diff) | |
download | scala-09e5446bd38a91f097b19549e5d7f1342b6bbfc4.tar.gz scala-09e5446bd38a91f097b19549e5d7f1342b6bbfc4.tar.bz2 scala-09e5446bd38a91f097b19549e5d7f1342b6bbfc4.zip |
*** empty log message ***
-rw-r--r-- | sources/scala/tools/nsc/matching/CodeFactory.scala | 13 | ||||
-rw-r--r-- | sources/scala/tools/nsc/matching/PatternMatchers.scala | 8 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/symtab/Definitions.scala | 2 |
3 files changed, 22 insertions, 1 deletions
diff --git a/sources/scala/tools/nsc/matching/CodeFactory.scala b/sources/scala/tools/nsc/matching/CodeFactory.scala index f9f745e1e1..f2d4b30dcb 100644 --- a/sources/scala/tools/nsc/matching/CodeFactory.scala +++ b/sources/scala/tools/nsc/matching/CodeFactory.scala @@ -207,7 +207,17 @@ import scala.tools.nsc.util.Position; // } def ThrowMatchError(pos: Int, tpe: Type ) = - Apply( + atPos(pos) { + Throw( + New( + TypeTree(definitions.MatchErrorClass.tpe), + List(List( + Literal(cunit.toString()), + Literal(Position.line(cunit.source, pos)))))) + } + +/* + Apply( TypeApply( gen.mkRef(definitions.MatchError_fail), List(TypeTree(tpe)) @@ -217,6 +227,7 @@ import scala.tools.nsc.util.Position; Literal(Position.line(cunit.source, pos)) ) ); +*/ /* // ?! def ThrowMatchError(pos:int , tree:Tree ) = diff --git a/sources/scala/tools/nsc/matching/PatternMatchers.scala b/sources/scala/tools/nsc/matching/PatternMatchers.scala index 9c3e7793ad..592ce40827 100644 --- a/sources/scala/tools/nsc/matching/PatternMatchers.scala +++ b/sources/scala/tools/nsc/matching/PatternMatchers.scala @@ -741,12 +741,20 @@ trait PatternMatchers: (TransMatcher with PatternNodes) extends AnyRef with Patt val result = exit.newValueParameter(root.pos, "result").setInfo( resultType ); //Console.println("generalSwitchToTree: "+root.or); + /* val ts = List(ValDef(root.symbol, selector)); val res = If(toTree(root.and), LabelDef(exit, List(result), Ident(result)), ThrowMatchError(selector.pos, resultType // , Ident(root.symbol) )); return Block(ts, res); + */ + return Block( + List( + ValDef(root.symbol, selector), + toTree(root.and), + ThrowMatchError(selector.pos, resultType)), + LabelDef(exit, List(result), Ident(result))) } /*protected*/ def toTree(node1: PatternNode): Tree = { diff --git a/sources/scala/tools/nsc/symtab/Definitions.scala b/sources/scala/tools/nsc/symtab/Definitions.scala index 0469abe219..47700f06d8 100755 --- a/sources/scala/tools/nsc/symtab/Definitions.scala +++ b/sources/scala/tools/nsc/symtab/Definitions.scala @@ -72,6 +72,7 @@ import Flags._; var SerializableClass: Symbol = _; var PredefModule: Symbol = _; var ConsoleModule: Symbol = _; + var MatchErrorClass: Symbol = _; var MatchErrorModule: Symbol = _; def MatchError_fail = getMember(MatchErrorModule, "fail"); def MatchError_report = getMember(MatchErrorModule, "report"); @@ -339,6 +340,7 @@ import Flags._; SerializableClass = getClass("java.io.Serializable"); PredefModule = getModule("scala.Predef"); ConsoleModule = getModule("scala.Console"); + MatchErrorClass = getClass("scala.MatchError"); MatchErrorModule = getModule("scala.MatchError"); ScalaRunTimeModule = getModule("scala.runtime.ScalaRunTime"); RepeatedParamClass = newCovariantPolyClass( |