summaryrefslogtreecommitdiff
path: root/test/files/run/t5830.check
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-02 10:55:40 +0200
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-03 15:43:00 +0200
commit64acb46ab796a01bb5186385b7f8568748a857be (patch)
tree085582b323bceb452731ad84f23a2e3d7c228ea9 /test/files/run/t5830.check
parentbc2e6fe8bf20b2aa985ea78a2c610ac33497da38 (diff)
downloadscala-64acb46ab796a01bb5186385b7f8568748a857be.tar.gz
scala-64acb46ab796a01bb5186385b7f8568748a857be.tar.bz2
scala-64acb46ab796a01bb5186385b7f8568748a857be.zip
SI-5830 switches: support guards, unreachability
turn switches with guards into guard-free switches by collecting all cases that are (possibly) guarded by different guards but that switch on the same constant, and pushing the implied if-then-else into the collapsed case body ``` case C if G1 => B1 case C if Gi => Bi case C if GN => BN ``` becomes ``` case C => if (G1) B1 else if (Gi) Bi else if (GN) BN else default() // not necessary if GN == EmptyTree ``` default() is a jump to the default case; to enable this, we wrap a default() { } labeldef around the last case's body (the user-defined default or the synthetic case that throws the matcherror) so we can jump to the default case after the last guard is checked (assuming unreachability is checked, once we ended up in a non-default case, one of the guards either matches or we go to the default case) the unreachability analysis is minimal -- we simply check (after rewriting to guard-free form) that: - there are no duplicate cases - the default case comes last misc notes: - can't jump in exception handlers (TODO: a more fine-grained analysis on when we need to jump) - work around SI-6015 (test file run/t5830.scala crashed the inliner) - propagate type of case body to label def of default case (needed for existentials, see e.g., t2683) - the default(){} LabelDef breaks SelectiveANFTransform -- workaround: don't write guarded switches in CPS code (do the above transformation manually)
Diffstat (limited to 'test/files/run/t5830.check')
-rw-r--r--test/files/run/t5830.check6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/files/run/t5830.check b/test/files/run/t5830.check
new file mode 100644
index 0000000000..675387eb8e
--- /dev/null
+++ b/test/files/run/t5830.check
@@ -0,0 +1,6 @@
+a with oef
+a with oef
+a
+def with oef
+def
+default