diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-12-15 17:33:57 +0100 |
---|---|---|
committer | Adriaan Moors <adriaanm@gmail.com> | 2011-12-24 17:37:15 +0100 |
commit | d4182c7f1473c8c831644da1a473e829345ce5a4 (patch) | |
tree | 7354ab603ac8f65555b30ac2c7da8bea08ece8cf /test/files | |
parent | 0be2888938098f26a59115550073dde7f5dd7bd1 (diff) | |
download | scala-d4182c7f1473c8c831644da1a473e829345ce5a4.tar.gz scala-d4182c7f1473c8c831644da1a473e829345ce5a4.tar.bz2 scala-d4182c7f1473c8c831644da1a473e829345ce5a4.zip |
[vpm] emitting switches -- BodyTreeMaker
1) introduce BodyTreeMaker to get rid of special casing for body
now each case is a list of TreeMakers rather than a pair of such a list and a tree
needed to do this since emitting switches requires access to the untranslated body
2) emitting switches
- alternatives are flattened: each alternative block ends with a jump to the next alternative (if there is one)
- to avoid stack overflow in typedMatch: detect when translateMatch returns a Match
the patch to uncurry would be nicer with an extractor, but that breaks due to a bug in old patmat
made trees into dags again -- NPE in erasure
tree.duplicate seems to break lambdalift because it
does not give fresh symbols (or trees?) to the valdefs
for the arguments of duplicated functions
duplicate enclosing tree, not subtrees
improved propagateSubstitution for AlternativesTreeMaker
- it now propagates to all its alternatives, so we don't have to do that in chainBefore
- by making propagation more regular, a bug in substitution in AlternativesTreeMaker manifested itself
it introduced a new binder, unnecessarily, which then was unbound -- now reusing binder of outer pattern
having removeSubstOnly in propagateSubstitution unveiled a bug: guard treemaker should substitute
move fixerUpper closer to what it fixes up
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/pos/virtpatmat_alts_subst.flags | 1 | ||||
-rw-r--r-- | test/files/pos/virtpatmat_alts_subst.scala | 6 | ||||
-rw-r--r-- | test/files/pos/virtpatmat_binding_opt.flags | 1 | ||||
-rw-r--r-- | test/files/pos/virtpatmat_binding_opt.scala | 11 | ||||
-rw-r--r-- | test/files/run/virtpatmat_literal.scala | 3 |
5 files changed, 21 insertions, 1 deletions
diff --git a/test/files/pos/virtpatmat_alts_subst.flags b/test/files/pos/virtpatmat_alts_subst.flags new file mode 100644 index 0000000000..9769db9257 --- /dev/null +++ b/test/files/pos/virtpatmat_alts_subst.flags @@ -0,0 +1 @@ + -Yvirtpatmat -Xexperimental diff --git a/test/files/pos/virtpatmat_alts_subst.scala b/test/files/pos/virtpatmat_alts_subst.scala new file mode 100644 index 0000000000..e27c52f9c7 --- /dev/null +++ b/test/files/pos/virtpatmat_alts_subst.scala @@ -0,0 +1,6 @@ +case class Foo(s: String) { + def appliedType(tycon: Any) = + tycon match { + case Foo(sym @ ("NothingClass" | "AnyClass")) => println(sym) + } +} diff --git a/test/files/pos/virtpatmat_binding_opt.flags b/test/files/pos/virtpatmat_binding_opt.flags new file mode 100644 index 0000000000..9769db9257 --- /dev/null +++ b/test/files/pos/virtpatmat_binding_opt.flags @@ -0,0 +1 @@ + -Yvirtpatmat -Xexperimental diff --git a/test/files/pos/virtpatmat_binding_opt.scala b/test/files/pos/virtpatmat_binding_opt.scala new file mode 100644 index 0000000000..962e3d7dbe --- /dev/null +++ b/test/files/pos/virtpatmat_binding_opt.scala @@ -0,0 +1,11 @@ +class Test { + def combine = this match { + case that if that eq this => this // just return this + case that: Test2 => + println(that) + this + case _ => error("meh") + } +} + +class Test2 extends Test
\ No newline at end of file diff --git a/test/files/run/virtpatmat_literal.scala b/test/files/run/virtpatmat_literal.scala index cb72b1d2a5..5bd6b30791 100644 --- a/test/files/run/virtpatmat_literal.scala +++ b/test/files/run/virtpatmat_literal.scala @@ -1,8 +1,9 @@ object Test extends App { + val a = 1 1 match { case 2 => println("FAILED") case 1 => println("OK") - case 1 => println("FAILED") + case `a` => println("FAILED") } val one = 1 |