summaryrefslogtreecommitdiff
path: root/test/pending/pos/no-widen-locals.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-05-22 11:03:42 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-05-22 11:34:08 +0200
commit0497c1513b9c8e561e16ebb56a004b5baabf8ecd (patch)
treeb931cbe279484621f4849c510588a0ee89c4bb1e /test/pending/pos/no-widen-locals.scala
parentf406550146250f5a6036d3d778582efa6d68252a (diff)
downloadscala-0497c1513b9c8e561e16ebb56a004b5baabf8ecd.tar.gz
scala-0497c1513b9c8e561e16ebb56a004b5baabf8ecd.tar.bz2
scala-0497c1513b9c8e561e16ebb56a004b5baabf8ecd.zip
TreeMaker approximation refactorings and bug fixes
- TypeTestTreeMaker subsumes the old TypeTestTM and TypeAndEqualityTM its type- and equality-testing logic is configurable so that it can: - generate trees (main purpose) - check whether this tree maker is a pure type test - generate the proposition that models this tree maker (for exhaustivity and other analyses) - [CSE] subst binders of dropped tm's to stored ones somehow the refactoring broke the replacement of the binder of dropped treemakers by the binder of the reused treemaker when replacing TM1(x1 => ...) >> TM2(x2 => ...) >> TM3(x3 => ...) >> ... TM1'(x1' => ...) >> TM2'(x2' => ...) >> TM3(x3' => ...) >> ... by Memo1(x1 => ...) >> TM2(x2 => ...) >> Memo2(x3 => ...) >> ... Reuse(Memo2)... you need to replace x1' and x2' by x1 since TM2 tested a shared condition but was not memo-ised, that implies it simply passed x1 through to x3 unmodified, and x2' can simply use the stored x1 - type of first uniqued binder sets type of tree when approximating a tree of treemakers as a DAG, where sharing indicates the same value is tested, use the type of the binder that was first used to create a unique tree as the type of that tree, and thus all trees used for the same binder in the future - track substitution of alternatives when approximating - error on unswitchable @switch annotated matches if we can't turn a match (with more than two cases) into a switch, but the user insists, emit an error misc notes: - when all you need is nextBinder, FunTreeMaker is your guy - must pass flag to TypeTestTM for extractorarg test case TypeTestTreeMaker(prevBinder, testedBinder, expectedTp, nextBinderTp) (prevBinder eq testedBinder) does not imply it's a pure type test for an extractor call note that the expected type for an extractor argument is not a type pattern, thus we only do a classic type test -- the idea was to detect that case by noticing we're being called with the same previous and tested binder, but that case also arises for Typed patterns
Diffstat (limited to 'test/pending/pos/no-widen-locals.scala')
-rw-r--r--test/pending/pos/no-widen-locals.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/pending/pos/no-widen-locals.scala b/test/pending/pos/no-widen-locals.scala
new file mode 100644
index 0000000000..013e63f0a2
--- /dev/null
+++ b/test/pending/pos/no-widen-locals.scala
@@ -0,0 +1,19 @@
+// Worked from r23262 until that was reverted somewhere
+// around r25016.
+import annotation.switch
+
+object Test {
+ def f(x: Int) = {
+ val X1 = 5
+ val X2 = 10
+ val X3 = 15
+ val X4 = 20
+
+ (x: @switch) match {
+ case X1 => 1
+ case X2 => 2
+ case X3 => 3
+ case X4 => 4
+ }
+ }
+}