Open
Description
Compiler version
3.3.0, 3.3.1, 3.3.3 (works correctly in 3.4.0 and 3.4.1)
Minimized code
class ClassWithOption {
val a: Option[Int] = None
}
object Test {
def main(args: Array[String]) =
classOf[ClassWithOption].getDeclaredFields.foreach { field =>
println(field.toString + " parametrised " + field.getGenericType.isInstanceOf[java.lang.reflect.ParameterizedType])
}
}
Output
In LTS:
private final scala.Option ClassWithOption.a parametrised false
In 3.4.0 and 3.4.1:
private final scala.Option ClassWithOption.a parametrised true
When using the CFR decompiler on ClassWIthOption I get:
In LTS:
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* scala.None$
* scala.Option
*/
import scala.None$;
import scala.Option;
public class ClassWithOption {
private final Option a = None$.MODULE$;
public Option<Object> a() {
return this.a;
}
}
In 3.4:
/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* scala.None$
* scala.Option
*/
import scala.None$;
import scala.Option;
public class ClassWithOption {
private final Option<Object> a = None$.MODULE$;
public Option<Object> a() {
return this.a;
}
}
Expectation
I expect the behavior in 3.4.
Some libraries may use java reflection features which depend on the erased type parameter being there. I suspect overeager type parameter erasure was not intentional, which is why it came back in 3.4.