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

specialize anonymous classes inside specialized methods #3457

Closed
scabug opened this issue May 20, 2010 · 4 comments
Closed

specialize anonymous classes inside specialized methods #3457

scabug opened this issue May 20, 2010 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented May 20, 2010

There is no value$$int in A$$Int.foo$$int.

object bug {
  trait B[@specialized(Int) T] {
    def value: T 
  }

  class A[@specialized(Int) T](x: T) { 
    def foo: B[T] = new B[T] { 
      def value = x 
    } 
  }

  def main(args: Array[String]) {
    println((new A("abc")).foo.value)
    println((new A(10)).foo.value)
  }
}
@scabug
Copy link
Author

scabug commented May 20, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3457?orig=1
Reporter: @dragos

@scabug
Copy link
Author

scabug commented Mar 4, 2011

@soc said:
Scala 2.9.0.r24324-b20110222020042:

Classes emitted:

bug$$A$$mcI$$sp$$$$anon$$2.class          bug$$B$$mcI$$sp.class
bug$$A$$mcI$$sp.class                  bug$$B$$mcI$$sp$$class.class
bug$$A$$$$anon$$1.class      bug$$B.class             bug.class
bug$$A.class              bug$$B$$class.class       bug$$.class

javap -c 'bug$$A$$$$anon$$1'

Compiled from "bug.scala"
public final class bug$$A$$$$anon$$1 extends java.lang.Object implements bug$$B{
public int value$$mcI$$sp();
  Code:
   0:	aload_0
   1:	invokestatic	SI-13; //Method bug$$B$$class.value$$mcI$$sp:(Lbug$$B;)I
   4:	ireturn

public java.lang.Object value();
  Code:
   0:	aload_0
   1:	getfield	SI-19; //Field $$outer:Lbug$$A;
   4:	getfield	SI-25; //Field bug$$A.x:Ljava/lang/Object;
   7:	areturn

public bug$$A$$$$anon$$1(bug$$A);
  Code:
   0:	aload_1
   1:	ifnonnull	12
   4:	new	SI-31; //class java/lang/NullPointerException
   7:	dup
   8:	invokespecial	SI-34; //Method java/lang/NullPointerException."<init>":()V
   11:	athrow
   12:	aload_0
   13:	aload_1
   14:	putfield	SI-19; //Field $$outer:Lbug$$A;
   17:	aload_0
   18:	invokespecial	SI-37; //Method java/lang/Object."<init>":()V
   21:	aload_0
   22:	invokestatic	SI-41; //Method bug$$B$$class.$$init$$:(Lbug$$B;)V
   25:	return
}

javap -c 'bug$$A$$mcI$$sp'

Compiled from "bug.scala"
public class bug$$A$$mcI$$sp extends bug$$A{
public final int x$$mcI$$sp;

public bug$$B foo();
  Code:
   0:	aload_0
   1:	invokevirtual	SI-13; //Method foo$$mcI$$sp:()Lbug$$B;
   4:	areturn

public bug$$B foo$$mcI$$sp();
  Code:
   0:	new	SI-17; //class bug$$A$$mcI$$sp$$$$anon$$2
   3:	dup
   4:	aload_0
   5:	invokespecial	SI-21; //Method bug$$A$$mcI$$sp$$$$anon$$2."<init>":(Lbug$$A$$mcI$$sp;)V
   8:	areturn

public bug$$A$$mcI$$sp(int);
  Code:
   0:	aload_0
   1:	iload_1
   2:	putfield	SI-24; //Field x$$mcI$$sp:I
   5:	aload_0
   6:	iload_1
   7:	invokestatic	SI-30; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
   10:	invokespecial	SI-35; //Method bug$$A."<init>":(Ljava/lang/Object;)V
   13:	return
}

javap -c 'bug$$A$$mcI$$sp$$$$anon$$2'

Compiled from "bug.scala"
public final class bug$$A$$mcI$$sp$$$$anon$$2 extends java.lang.Object implements bug$$B{
public int value$$mcI$$sp();
  Code:
   0:	aload_0
   1:	invokestatic	SI-13; //Method bug$$B$$class.value$$mcI$$sp:(Lbug$$B;)I
   4:	ireturn

public int value();
  Code:
   0:	aload_0
   1:	getfield	SI-18; //Field $$outer:Lbug$$A$$mcI$$sp;
   4:	getfield	SI-24; //Field bug$$A$$mcI$$sp.x$$mcI$$sp:I
   7:	ireturn

public java.lang.Object value();
  Code:
   0:	aload_0
   1:	invokevirtual	SI-27; //Method value:()I
   4:	invokestatic	SI-33; //Method scala/runtime/BoxesRunTime.boxToInteger:(I)Ljava/lang/Integer;
   7:	areturn

public bug$$A$$mcI$$sp$$$$anon$$2(bug$$A$$mcI$$sp);
  Code:
   0:	aload_1
   1:	ifnonnull	12
   4:	new	SI-37; //class java/lang/NullPointerException
   7:	dup
   8:	invokespecial	SI-40; //Method java/lang/NullPointerException."<init>":()V
   11:	athrow
   12:	aload_0
   13:	aload_1
   14:	putfield	SI-18; //Field $$outer:Lbug$$A$$mcI$$sp;
   17:	aload_0
   18:	invokespecial	SI-43; //Method java/lang/Object."<init>":()V
   21:	aload_0
   22:	invokestatic	SI-47; //Method bug$$B$$class.$$init$$:(Lbug$$B;)V
   25:	return
}

Did this specialize it as expected?

@scabug
Copy link
Author

scabug commented Feb 21, 2012

@non said:
While this code doesn't do all the things one might want, it seems to basically be doing what I'd expect given where specialization is at right now. Given that the method exists (AFAIK) and the bug description is very broad, I consider this bug closed.

Could we either close this bug, or get an updated problem statement (i.e. a program whose output is wrong)?

@scabug scabug closed this as completed May 3, 2012
@scabug
Copy link
Author

scabug commented May 3, 2012

@paulp said:
Agreed, given the state and direction of specialization, I think we should just declare this wontfix.

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