bug
bug copied to clipboard
PatMat creates shadowing locals, references to them could not be re-typed
Discussed in https://github.com/scala/scala/pull/4033
The following creates two locals named x2. The tuple construction uses symbolic references, but could not be re-typed due to shadowing.
scala> class C {
| final def resume: Unit = (this: Any) match {
| case x : C => (x: Any) match {
| case y : C =>
| () => (x, y)
| }
| }
| }
[[syntax trees at end of patmat]] // <console>
[...]
final def resume: Unit = {
case <synthetic> val x1: Any = (this: Any);
case5(){
if (x1.isInstanceOf[C])
{
<synthetic> val x2: C = (x1.asInstanceOf[C]: C);
matchEnd4({
case <synthetic> val x1: Any = (x2: Any);
case5(){
if (x1.isInstanceOf[C])
{
<synthetic> val x2: C = (x1.asInstanceOf[C]: C);
matchEnd4({
(() => scala.Tuple2.apply[C, C](x2, x2));
()
})
}
[...]
Imported From: https://issues.scala-lang.org/browse/SI-8889?orig=1 Reporter: @lrytz Affected Versions: 2.11.2 See #8888
"could not be re-typed" — under what circumstances does re-typing occur? how does the problem manifest downstream?