Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.12 with indylambda creates invalid bytecode #9387

Closed
scabug opened this issue Jul 8, 2015 · 3 comments
Closed

2.12 with indylambda creates invalid bytecode #9387

scabug opened this issue Jul 8, 2015 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 8, 2015

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;
@scabug
Copy link
Author

scabug commented Jul 8, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9387?orig=1
Reporter: @lrytz
Other Milestones: 2.12.0-M2

@scabug
Copy link
Author

scabug commented Jul 8, 2015

@SethTisue said:
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

@scabug
Copy link
Author

scabug commented Jul 9, 2015

@retronym said:
scala/scala#4617

@scabug scabug closed this as completed Jul 9, 2015
@scabug scabug added this to the 2.11.8 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants