Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-9387

2.12 with indylambda creates invalid bytecode

    Details

      Description

      class G[T]
      object G {
        def v[T](x: T): G[T] = null
      }
       
      class A[T]
      object A {
        def apply[T](x: => G[T]): A[T] = null
      }
       
      object T {
        A[Unit](G.v(() => ()))
      }
      

      yields

      java.lang.VerifyError: Bad type on operand stack
      Exception Details:
        Location:
          T$.T$$$anonfun$1()LG; @11: invokevirtual
        Reason:
          Type 'scala/runtime/java8/JFunction0$mcV$sp' (current frame, stack[1]) is not assignable to 'G$'
      

      2.12 generates:

          GETSTATIC G$.MODULE$ : LG$;
          INVOKEDYNAMIC [pushes closure onto stack]
          GETSTATIC scala/runtime/BoxedUnit.UNIT : Lscala/runtime/BoxedUnit;
          INVOKEVIRTUAL G$.v (Ljava/lang/Object;)LG;
      

      a pop is missing. compare with the code generated by 2.11 with delambdafy:method and GenBCode

          GETSTATIC G$.MODULE$ : LG$;
          NEW T$$anonfun$$nestedInanonfun$1$1
          DUP
          INVOKESPECIAL T$$anonfun$$nestedInanonfun$1$1.<init> ()V
          POP
          GETSTATIC scala/runtime/BoxedUnit.UNIT : Lscala/runtime/BoxedUnit;
          INVOKEVIRTUAL G$.v (Ljava/lang/Object;)LG;
      

        Attachments

          Activity

          Hide
          sethtisue Seth Tisue added a comment -

          This was uncovered by sbinary's test suite, running in the new 2.12 community build; https://scala-ci.typesafe.com/view/scala-2.12.x/job/scala-2.12.x-integrate-community-build/18/console shows it happening

          Show
          sethtisue Seth Tisue added a comment - This was uncovered by sbinary's test suite, running in the new 2.12 community build; https://scala-ci.typesafe.com/view/scala-2.12.x/job/scala-2.12.x-integrate-community-build/18/console shows it happening
          Show
          retronym Jason Zaugg added a comment - https://github.com/scala/scala/pull/4617

            People

            • Assignee:
              retronym Jason Zaugg
              Reporter:
              rytz Lukas Rytz
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: