Closed
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;