Scala Programming Language
  1. Scala Programming Language
  2. SI-6997

VerifyError with captured object local to super arg

    Details

      Description

      I created this test case during the investigations for SI-6666, but I think it's a slightly different issue.

      We might end up needing a similar solution (an implementation restriction on what can be captured in this context), but first we should investigate the manner in which this gets to the VerifyError.

      First place to look is at the code surrounding the log message "Couldn't determine how to properly construct variable Nested$module".

      ticket/6666 ~/code/scala2 cat sandbox/test.scala
      class C(a: Any)
      object O4 extends C({
        object Nested
        Nested
      })
      O4
      ticket/6666 ~/code/scala2 scala210 -nc -Xprint:lambdalift -Ylog:lambdalift sandbox/test.scala 
      [log lambdalift] Renaming object Nested to Nested$1
      [log lambdalift] Renaming anonymous class $anon to $anon$1
      [log lambdalift] Renaming object Nested to Nested$2
      [log lambdalift(->constructors)] Couldn't determine how to properly construct variable Nested$module
      [[syntax trees at end of                lambdalift]] // test.scala
      package <empty> {
        object Main extends Object {
          def <init>(): Main.type = {
            Main.super.<init>();
            ()
          };
          def main(argv: Array[String]): Unit = {
            val args: Array[String] = argv;
            {
              {
                new anonymous class $anon$1();
                ()
              }
            }
          };
          final class $anon$1 extends Object {
            def <init>(): anonymous class $anon$1 = {
              $anon$1.super.<init>();
              ()
            };
            class C extends Object {
              <paramaccessor> private[this] val a: Object = _;
              def <init>($outer: anonymous class $anon$1, a: Object): this.C = {
                C.super.<init>();
                ()
              };
              <synthetic> <paramaccessor> protected val $outer: anonymous class $anon$1 = _;
              <synthetic> <stable> def Main$$anon$C$$$outer(): anonymous class $anon$1 = C.this.$outer
            };
            object O4 extends C {
              def <init>($outer: anonymous class $anon$1): this.O4.type = {
                O4.super.<init>($outer, {
                  @volatile var Nested$module: runtime.VolatileObjectRef = new runtime.VolatileObjectRef(<empty>);
                  O4.this.Nested$1(Nested$module, $outer)
                });
                ()
              };
              <synthetic> <stable> def Main$$anon$O4$$$outer(): anonymous class $anon$1 = O4.this.$outer;
              object Nested$2 extends Object {
                def <init>($outer: anonymous class $anon$1): O4.Nested$2.type = {
                  Nested$2.super.<init>();
                  ()
                };
                <synthetic> <paramaccessor> private[this] val $outer: anonymous class $anon$1 = _;
                <synthetic> <stable> def Main$$anon$O4$Nested$$$outer(): anonymous class $anon$1 = Nested$2.this.$outer
              };
              final <stable> private[this] def Nested$1(Nested$module$1: runtime.VolatileObjectRef, $outer$1: anonymous class $anon$1): O4.Nested$2.type = {
                Nested$module$1.elem = new O4.Nested$2.type($outer$1);
                Nested$module$1.elem.$asInstanceOf[O4.Nested$2.type]()
              }
            };
            @volatile <synthetic> private[this] var O4$module: O4.type = _;
            <stable> private def O4(): O4.type = {
              $anon$1.this.O4$module = new O4.type($anon$1.this);
              $anon$1.this.O4$module
            };
            $anon$1.this.O4()
          }
        }
      }
      
      java.lang.VerifyError: (class: Main$$anon$1$O4$, method: <init> signature: (LMain$$anon$1;)V) Expecting to find object/array on stack
      	at Main$$anon$1.O4$lzycompute(test.scala:2)
      

        Issue Links

          Activity

          Hide
          James Iry added a comment -

          Fixing the "Couldn't properly determine" bit in SI-7011 had no effect on this bug. This one is another form of SI-6957 / SI-6666.

          Show
          James Iry added a comment - Fixing the "Couldn't properly determine" bit in SI-7011 had no effect on this bug. This one is another form of SI-6957 / SI-6666 .

            People

            • Assignee:
              James Iry
              Reporter:
              Jason Zaugg
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development