I found this piece of code:
Class<? extends Enum> enumClass = Class.forName(Charsets.class.getName())
.asSubclass(Enum.class);
and I wanted to refactor it using Lombok, but something unexpected happened. When I changed it to:
val enumClass = Class.forName(Charsets.class.getName())
.asSubclass(Enum.class);
I got this error:
What's suprising is that the code compiles fine, and test that uses it passes.
I am unsure whether it is a bug in the Lombok Plugin, IDE or if I am doing something wrong. Shouldn't Lombok be able to easily infer the correct type of the variable?
My question is: can I use that code safely or should I revert to the original?
I am using the most recent (at this time) InteliiJ:
IntelliJ IDEA 2016.3
Build #IU-163.7743.44, built on November 17, 2016
JRE: 1.8.0_112-release-408-b2 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
and Lombok Plugin:
Lombok Plugin
Version: 0.13.16
Preferences > Plugins
> install the latest version of Lombok plugin for IntelliJ
Confirmed to work with IntelliJ IDEA 2018.1.1 and Lombok Plugin 0.17-2018.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With