summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2006-10-19 12:36:19 +0000
committerBurak Emir <emir@epfl.ch>2006-10-19 12:36:19 +0000
commit2cf278b25baf138c0a9775bcbe7bc97b4b548139 (patch)
treee63559465e6f4d8cbefe7259e089e6a56603bf34 /src
parent00db012c72614355680834516ccd649cf48d63ac (diff)
downloadscala-2cf278b25baf138c0a9775bcbe7bc97b4b548139.tar.gz
scala-2cf278b25baf138c0a9775bcbe7bc97b4b548139.tar.bz2
scala-2cf278b25baf138c0a9775bcbe7bc97b4b548139.zip
fix 781, nullpointerexcs in matcherror
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternMatchers.scala6
-rw-r--r--src/library/scala/MatchError.scala9
2 files changed, 10 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
index 27c5792069..145190f1ed 100644
--- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
+++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
@@ -366,7 +366,9 @@ trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes) {
//Console.println("tree.getClass() "+tree.getClass());
tree match {
case Bind(name, Typed(Ident( nme.WILDCARD ), tpe)) => // x@_:Type
- if (isSubType(header.getTpe(),tpe.tpe)) {
+ if (false && isSubType(header.getTpe(),tpe.tpe)) {
+ // this optimization is not correct, because
+ // null.isInstanceOf will return false
val node = pDefaultPat(tree.pos, tpe.tpe)
env.newBoundVar(tree.symbol, tree.tpe, header.selector)
node
@@ -1002,7 +1004,7 @@ trait PatternMatchers requires (transform.ExplicitOuter with PatternNodes) {
); // forward jump
if (guard(i) != EmptyTree)
res0 = And(guard(i), res0);
- res = Or(Block(ts.toList, res0), res);
+ res = Or(squeezedBlock(ts.toList, res0), res);
i = i - 1
}
if (_b.or != null)
diff --git a/src/library/scala/MatchError.scala b/src/library/scala/MatchError.scala
index a26c5087ce..6ef969b97c 100644
--- a/src/library/scala/MatchError.scala
+++ b/src/library/scala/MatchError.scala
@@ -23,13 +23,16 @@ import Predef._
*/
object MatchError {
+ def string(obj: Any) =
+ if(obj != null) obj.toString() else "null"
+
// todo: change pattern matcher so that dummy type parameter T can be removed.
def fail[T](source: String, line: Int): Nothing =
throw new MatchError(source, line)
def report(source: String, line: Int, obj: Any) =
try {
- throw new MatchError(source, line, obj.toString())
+ throw new MatchError(source, line, string(obj))
} catch {
case e: MatchError => throw e
case e: Throwable => throw new MatchError(source, line)
@@ -43,6 +46,6 @@ final class MatchError(msg: String) extends Error(msg) {
def this(source: String, line: Int, obj: String) =
this("for object " + obj + " in '" + source + "' at line " + line)
- def this(ob: Any) =
- this(ob.toString())
+ def this(obj: Any) =
+ this(MatchError.string(obj))
}