scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

@specialized class retains as fields unnecessary constructor parameters. #12929

Closed noresttherein closed 5 months ago

noresttherein commented 5 months ago

Reproduction steps

I can't belive there is no bug for it already, but I genuinly couldn't find one.

Scala version: 2.13.12

class Spec[@specialized(Int) A](x :Int)

Problem

turin@turin-ThinkPad-X250:~/porn/sugar$ javap -p target/scala-2.13/test-classes/Spec.class 
Compiled from "Playground.scala"
public class Spec<A> {
  public Spec(int);
}
turin@turin-ThinkPad-X250:~/porn/sugar$ javap -p target/scala-2.13/test-classes/Spec\$mcI\$sp.class 
Compiled from "Playground.scala"
public class Spec$mcI$sp extends Spec<java.lang.Object> {
  private final int x;
  public Spec$mcI$sp(int);
}

Spec$mcI$sp doesn't need private final int x.

som-snytt commented 5 months ago

Whenever we said, "I can't believe [whatever seemed incommensurable to us]!", my father would say, "Believe it! Believe it!"