-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Constructors are unnecessarily given Java generic signatures #10834
Comments
|
I think some guice DI does not work due to this issue 😢
|
It seems that we're missing https://github.com/scala/scala/pull/7975/files#diff-271d576b3a80359cbc5db9e1a8dd2629c2cb1d99bf8a30854c64742f98c7a6b0R78-R87 which ensures that we do not generate signatures for constructors whose parameters don't refer to a class type parameter, but I don't know if this is related to @xuwei-k's issue since in his case the type parameter is used so it's normal to have a signature on the constructor. |
For reference, the corresponding code in scala 3 is in https://github.com/lampepfl/dotty/blob/601184787508d8fd655f1dc4e48ed19c418fa710/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala#L455 |
another Java Interop problemMain.javapackage example;
public class Main {
public static void main(String[] args) {
A<Integer> a = new A<>("x");
int x = a.x();
}
} A.scalapackage example
class A[X](val x: X) Scala 2.13.6compile error
Scala 3.0.2-RC1-bin-20210706-6011847-NIGHTLYruntime error
|
Nice example, it looks like javac takes the wrong signatures as building a |
corresponding code in Scala 2 |
Minimized code
Output
Expectation
No Signature on the constructor. Compare against the equivalent Java:
(Signature #9 is the class Signature.) Scala 2 doesn't emit this, which I perceive as correct.
This came up in the context of trialing MiMa on different versions of a library compiled with the Scala 3 compiler and some changes are resulting in additional, unexpected constructor signature changes - however signature checking is an opt-in feature of MiMa, so this wouldn't affect all MiMa users.
The text was updated successfully, but these errors were encountered: