Open dnadolny opened 11 years ago
Another case of a dropped constructor:
public class A extends B<String, Map<String, Double>> {
private static final long serialVersionUID = 1L;
public A() {
super(new C<Map<String, Double>>() {
public D<String, Double> z() {
return new E<String, Double>(0.0);
}
});
}
}
becomes:
@SerialVersionUID(1L)
class A extends B[String, Map[String, Double]]
The constructor usage optimization is not yet perfect, the sources are here https://github.com/mysema/scalagen/blob/master/scalagen/src/main/scala/com/mysema/scalagen/Constructors.scala
I don't think there is a valid way to convert the first example to Scala, but the second example should work
Technically the first one could be (class B(str: String) extends A(str) { def this() = this("some value") }
), although to do that would require knowing that the literal "some value" is a String, and that the B(String str) constructor doesn't do anything not done by B() (which, in this case, is just nothing).
It's probably not worth it to attempt to fix it, but how about putting a comment /* Unconverted constructor: (original Java here, or at least the signature) */
, or something to that effect?
Starting from the Java:
Converting the class B gives:
The default constructor that called
super("some value")
is silently dropped.