Skip to content

Instantly share code, notes, and snippets.

@retronym

retronym/specialize.log

Last active Aug 29, 2015
Embed
What would you like to do?
rm *.class; scalac -Xprint:typer,specialize sandbox/test.scala && javap -private C 'C$mcI$sp'
[[syntax trees at end of typer]] // test.scala
package <empty> {
class C[@specialized A] extends scala.AnyRef {
def <init>(): C[A] = {
C.super.<init>();
()
};
final private[this] def foo(a: A): A = a
}
}
[[syntax trees at end of specialize]] // test.scala
package <empty> {
class C[@specialized A] extends Object {
def <init>(): C[A] = {
C.super.<init>();
()
};
protected[this] def foo(a: A): A = a;
<specialized> protected[this] def foo$mcZ$sp(a: Boolean): Boolean = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Boolean]();
<specialized> protected[this] def foo$mcB$sp(a: Byte): Byte = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Byte]();
<specialized> protected[this] def foo$mcC$sp(a: Char): Char = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Char]();
<specialized> protected[this] def foo$mcD$sp(a: Double): Double = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Double]();
<specialized> protected[this] def foo$mcF$sp(a: Float): Float = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Float]();
<specialized> protected[this] def foo$mcI$sp(a: Int): Int = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Int]();
<specialized> protected[this] def foo$mcJ$sp(a: Long): Long = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Long]();
<specialized> protected[this] def foo$mcS$sp(a: Short): Short = C.this.foo(a.asInstanceOf[A]()).asInstanceOf[Short]();
<specialized> protected[this] def foo$mcV$sp(a: Unit): Unit = {
C.this.foo(a.asInstanceOf[A]());
()
}
};
<specialized> class C$mcB$sp extends C[Byte] {
<specialized> def <init>(): C$mcB$sp = {
C$mcB$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Byte): Byte = C$mcB$sp.this.foo$mcB$sp(a);
final override <specialized> protected[this] def foo$mcB$sp(a: Byte): Byte = a
};
<specialized> class C$mcC$sp extends C[Char] {
<specialized> def <init>(): C$mcC$sp = {
C$mcC$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Char): Char = C$mcC$sp.this.foo$mcC$sp(a);
final override <specialized> protected[this] def foo$mcC$sp(a: Char): Char = a
};
<specialized> class C$mcD$sp extends C[Double] {
<specialized> def <init>(): C$mcD$sp = {
C$mcD$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Double): Double = C$mcD$sp.this.foo$mcD$sp(a);
final override <specialized> protected[this] def foo$mcD$sp(a: Double): Double = a
};
<specialized> class C$mcF$sp extends C[Float] {
<specialized> def <init>(): C$mcF$sp = {
C$mcF$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Float): Float = C$mcF$sp.this.foo$mcF$sp(a);
final override <specialized> protected[this] def foo$mcF$sp(a: Float): Float = a
};
<specialized> class C$mcI$sp extends C[Int] {
<specialized> def <init>(): C$mcI$sp = {
C$mcI$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Int): Int = C$mcI$sp.this.foo$mcI$sp(a);
final override <specialized> protected[this] def foo$mcI$sp(a: Int): Int = a
};
<specialized> class C$mcJ$sp extends C[Long] {
<specialized> def <init>(): C$mcJ$sp = {
C$mcJ$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Long): Long = C$mcJ$sp.this.foo$mcJ$sp(a);
final override <specialized> protected[this] def foo$mcJ$sp(a: Long): Long = a
};
<specialized> class C$mcS$sp extends C[Short] {
<specialized> def <init>(): C$mcS$sp = {
C$mcS$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Short): Short = C$mcS$sp.this.foo$mcS$sp(a);
final override <specialized> protected[this] def foo$mcS$sp(a: Short): Short = a
};
<specialized> class C$mcV$sp extends C[Unit] {
<specialized> def <init>(): C$mcV$sp = {
C$mcV$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Unit): Unit = C$mcV$sp.this.foo$mcV$sp(a);
final override <specialized> protected[this] def foo$mcV$sp(a: Unit): Unit = a
};
<specialized> class C$mcZ$sp extends C[Boolean] {
<specialized> def <init>(): C$mcZ$sp = {
C$mcZ$sp.super.<init>();
()
};
final override <specialized> protected[this] def foo(a: Boolean): Boolean = C$mcZ$sp.this.foo$mcZ$sp(a);
final override <specialized> protected[this] def foo$mcZ$sp(a: Boolean): Boolean = a
}
}
Compiled from "test.scala"
public class C<A> {
public A foo(A);
public boolean foo$mcZ$sp(boolean);
public byte foo$mcB$sp(byte);
public char foo$mcC$sp(char);
public double foo$mcD$sp(double);
public float foo$mcF$sp(float);
public int foo$mcI$sp(int);
public long foo$mcJ$sp(long);
public short foo$mcS$sp(short);
public void foo$mcV$sp(scala.runtime.BoxedUnit);
public C();
}
Compiled from "test.scala"
public class C$mcI$sp extends C<java.lang.Object> {
public final int foo(int);
public final int foo$mcI$sp(int);
public final java.lang.Object foo(java.lang.Object);
public C$mcI$sp();
}
class C[@specialized A] {
private[this] final def foo(a: A) = a
}
@adriaanm

This comment has been minimized.

Copy link

@adriaanm adriaanm commented Jun 1, 2015

But is this also necessary for a specialized method of an object, as in the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.