bug icon indicating copy to clipboard operation
bug copied to clipboard

PatMat creates shadowing locals, references to them could not be re-typed

Open scabug opened this issue 11 years ago • 2 comments

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));
                            ()
                          })
                        }
                      [...]

scabug avatar Oct 07 '14 08:10 scabug

Imported From: https://issues.scala-lang.org/browse/SI-8889?orig=1 Reporter: @lrytz Affected Versions: 2.11.2 See #8888

scabug avatar Oct 07 '14 08:10 scabug

"could not be re-typed" — under what circumstances does re-typing occur? how does the problem manifest downstream?

SethTisue avatar Mar 13 '25 19:03 SethTisue