Skip to content

Instantly share code, notes, and snippets.

@lrytz
Created Nov 20, 2015
Embed
What would you like to do?
class C {
  @inline final def m8[T, U, V](f: (T, U) => V, x: T, y: U) = f(x, y)
  def t8 = {
    val fun = (x: Int, y: Double) => 1l + x + y.toLong
    m8(fun, 1, 2d)
  }
}

compiles to

public class C {
  public final m8(Lscala/Function2;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    ALOAD 1
    ALOAD 2
    ALOAD 3
    INVOKEINTERFACE scala/Function2.apply (Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    ARETURN

  public t8()J
    ICONST_1
    LDC 2.0
    INVOKESTATIC C.C$$$anonfun$1 (ID)J
    LRETURN

  public final static synthetic C$$$anonfun$1(ID)J
    LCONST_1
    ILOAD 0
    I2L
    LADD
    DLOAD 1
    D2L
    LADD
    LRETURN

All boxing / unboxing in t8 is eliminated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment