summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBurak Emir <emir@epfl.ch>2007-06-03 22:50:15 +0000
committerBurak Emir <emir@epfl.ch>2007-06-03 22:50:15 +0000
commit450979f77506c0375d7dcf84219dfd226d9da499 (patch)
treea0bb8b34ee8fefbc2eaa1fcacb83f7b7914cb1e1
parent724e68bab0d480fd9379afcbbb56ccc098770706 (diff)
downloadscala-450979f77506c0375d7dcf84219dfd226d9da499.tar.gz
scala-450979f77506c0375d7dcf84219dfd226d9da499.tar.bz2
scala-450979f77506c0375d7dcf84219dfd226d9da499.zip
some debug output for fatal errors during typing
-rw-r--r--src/compiler/scala/tools/nsc/matching/PatternMatchers.scala24
-rw-r--r--test/files/run/patmatnew.scala6
2 files changed, 26 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
index 691b2370c4..539834e692 100644
--- a/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
+++ b/src/compiler/scala/tools/nsc/matching/PatternMatchers.scala
@@ -1207,13 +1207,29 @@ print()
//ignore ;
}
- val succ = squeezedBlock(List(typed {ValDef(casted,
- if(isSubType(selector.tpe,ntpe)) selector.duplicate else typed(gen.mkAsInstanceOf(selector.duplicate, ntpe, true)))}),
- toTree(node.and))
+ val cast_untyped = gen.mkAsInstanceOf(selector.duplicate, ntpe, true)
+ val vdef_untyped = ValDef(casted,
+ if(isSubType(selector.tpe,ntpe))
+ selector.duplicate
+ else
+ cast_untyped)
+ try {
+
+ val vdef = typed { vdef_untyped }
+ val succ = squeezedBlock(List(vdef),toTree(node.and))
val fail = toTree(node.or, selector.duplicate)
return myIf(cond, succ, fail)
-
+ } catch {
+ case e:TypeError =>
+ Console.println("while typing vdef_untyped = "+vdef_untyped);
+ Console.println("casted.tpe = "+casted.tpe);
+ Console.println("(a) selector.tpe = "+selector.tpe);
+ Console.println("(b) pattern type(ntpe) = "+ntpe);
+ Console.println("isSubType(a, b) = "+isSubType(selector.tpe,ntpe))
+ Console.println("cast.type = "+(typed {cast_untyped}).tpe)
+ throw e
+ }
case SequencePat(casted, len) =>
val ntpe = node.tpe
diff --git a/test/files/run/patmatnew.scala b/test/files/run/patmatnew.scala
index 16336a516c..4f6649f8b6 100644
--- a/test/files/run/patmatnew.scala
+++ b/test/files/run/patmatnew.scala
@@ -97,6 +97,12 @@ object Test extends TestConsoleMain {
}
}
+ // also: this one from fannkuch
+ //def flips(l: List[int]): int = (l: @unchecked) match {
+ // case 1 :: ls => 0
+ // case n :: ls => flips((l take n reverse) ::: (l drop n)) + 1
+ //}
+
def runTest() = assertEquals("both", (Var("x"),Var("y")), f)
}