-
Notifications
You must be signed in to change notification settings - Fork 1.1k
No generic signature generated for type aliases #13103
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
Comments
I've tried to replicate your bug on the current master branch and failed. For me both methods look identical in the bytecode and have the same jvm signature ( |
If |
will work on another repro case |
if you clone twitter/util and run I was able to get a repro working as well. I can publish the project, but I've updated the issue description with it |
Thanks, the generic signatures we generate are: public static scala.Function0 getFunc();
public static scala.Function0<java.lang.Object> getFunc2(); By contrast, Scala 2 generates: public static scala.Function0<java.lang.Object> getFunc();
public static scala.Function0<java.lang.Object> getFunc2(); (neither compiler will emit anything referencing scala.Int since that erases to int which cannot be used as a generic type parameter, and Integer cannot be used here either for other reasons). So the issue appears to be that we fail to generate generic signatures for type aliases. |
Looks like a one line fix: diff --git compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala
index 9392d903857..f0405f1f7e9 100644
--- compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala
+++ compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala
@@ -455,7 +455,7 @@ object GenericSignatures {
private class NeedsSigCollector(using Context) extends TypeAccumulator[Boolean] {
override def apply(x: Boolean, tp: Type): Boolean =
if (!x)
- tp match {
+ tp.dealias match {
case RefinedType(parent, refinedName, refinedInfo) =>
val sym = parent.typeSymbol
if (sym == defn.ArrayClass) foldOver(x, refinedInfo) I'm on vacation, anyone wants to make the PR ? :) |
Why can't Integer be used? I've mentally built the model "scala.Int erases to int when it can, to Integer when it can't" (ignoring specialisation) - much like value classes. |
It looks like it would require extra bridges: scala/scala@e42733e (when generic signatures are available, javac uses them to derive the bytecode signatures it will emit in invoke* instructions instead of just reading the actual bytecode signature written in the classfile, this complicates our job a lot). |
@dwijnand ticket of record on this is scala/bug#4214 |
Compiler version: 3.0.1
Problem
Given
Scala
The generic signatures generated (as seen using javap) are:
Whereas in Scala 2 we get:
The text was updated successfully, but these errors were encountered: