diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-03-12 14:29:59 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-03-12 14:46:39 +0100 |
commit | 5ef842ec09b58208ab30ffb2b6773b95099b07e7 (patch) | |
tree | d7e2da5b61c71aa11181b790801f715015d03c22 /test | |
parent | 0fbd4422b2030bd7ec6299d99cac2eaf9a4a0ea9 (diff) | |
download | scala-5ef842ec09b58208ab30ffb2b6773b95099b07e7.tar.gz scala-5ef842ec09b58208ab30ffb2b6773b95099b07e7.tar.bz2 scala-5ef842ec09b58208ab30ffb2b6773b95099b07e7.zip |
SI-8395 Regression in pattern matching with nested binds
Regressed in https://github.com/scala/scala/pull/2848. In particular,
see 0cf47bdb5b and 017460e63c.
Because of the regression, this pattern:
(s @ (_s @ (_: String)))
was translated into `typeTestStep`, rather than a `bindingStep`. This
came down the the use of `unbind` in the `TypeBound` extractor.
My first step was to remove the `unbind`. That led to another
problem: the tree now matches `SymbolAndTypeBound`, which extracted
`symbol = s, tpe = String`, ignoring the `_s`. I changed that
extractor to no longer recursively apply to the sub-pattern tree,
which is what `MaybeTypedBound` used to do.
I also checked for other uses of `unbind` in the match translation.
The only place I found it is in `BoundTree#pt`. I believe that this
usage is correct, or at least, not obviously incorrect.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t8395.scala | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/files/run/t8395.scala b/test/files/run/t8395.scala new file mode 100644 index 0000000000..2570550619 --- /dev/null +++ b/test/files/run/t8395.scala @@ -0,0 +1,9 @@ + object Test { + def baz(x: Object) = { + val s @ (_s: String) = x + x + } + def main(args: Array[String]) { + assert(baz("1") == "1") + } +} |