summaryrefslogtreecommitdiff
path: root/test/files/pos/t7377/Client_2.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-04-17 09:19:21 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-04-17 13:05:08 +0200
commit15e9ef8f083e0c0dc75bf51a0784f56df2e2bea8 (patch)
tree4ace5c078ce2931263b5de50de77377faa3da778 /test/files/pos/t7377/Client_2.scala
parent4525e9223a2fb7c1ec3014073566b559e5839805 (diff)
downloadscala-15e9ef8f083e0c0dc75bf51a0784f56df2e2bea8.tar.gz
scala-15e9ef8f083e0c0dc75bf51a0784f56df2e2bea8.tar.bz2
scala-15e9ef8f083e0c0dc75bf51a0784f56df2e2bea8.zip
SI-7377 Fix retypechecking of patterns on case companion alias
Some ancient code in Typers switches from PATTERNmode to EXPRmode when encountering `stableF(...)`. It just typechecks `stableF` and discards the arguments. To the best of Martin's recollection, this has something to do with the need to typecheck patterns rather late in the compiler, after `a.b` had been translated to `a.b()` in `Uncurry`. I'm not able to motivate this with tests using `-Xoldpatmat`; was there ever an even older pattern matcher that ran *after* uncurry? What changed in 2.10.1 to expose this wrinkle? dfbaaa17 fixed `TypeTree.copyAttrs` to copy the original tree. During the descent of `ResetAttrs`, sub-trees are duplicated before begin further transformed. Duplicating the `Match` in 2.10.0 would forget that the original tree of: pat = (a: Int)Foo(_) `----------` `- TypeTree((a: Int)Foo), with original Select(..., "FooAlias") The retypechecking would operate on the `MethodType`, rather than the `Select`, which was not considered a stable application. For 2.10.x, I've just tightened up the condition to only hit this if `args` is empty. I'm almost certain that the code can be removed altogether, and I'll do that when this is merged to master.
Diffstat (limited to 'test/files/pos/t7377/Client_2.scala')
-rw-r--r--test/files/pos/t7377/Client_2.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/files/pos/t7377/Client_2.scala b/test/files/pos/t7377/Client_2.scala
new file mode 100644
index 0000000000..5728956cca
--- /dev/null
+++ b/test/files/pos/t7377/Client_2.scala
@@ -0,0 +1,11 @@
+object Test {
+ M.noop(List(1) match { case Nil => 0; case (x::xs) => x })
+
+ case class Foo(a: Int)
+ val FooAlias: Foo.type = Foo
+ M.noop(Foo(0) match { case FooAlias(_) => 0 })
+
+ case class Bar()
+ val BarAlias: Bar.type = Bar
+ M.noop(Bar() match { case BarAlias() => 0 })
+}