Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
4.0.3
-
None
-
None
Description
I have the following Groovy program.
class Main { static final Bar<? super Short> bar = new Bar<Short>((Short) -94) static final short foo = Main.bar.x } class Bar<P> { public final P x public Bar(P x) { this.x = x } }
Actual Behavior
The program does not compile, and I get the following error.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 5: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type short @ line 5, column 28. static final short foo = Main.bar.x ^ 1 error
Expected Behavior
Compile successfully.
Comment
Note that the equivalent Java program is accepted by javac.
Tested against 4.0.3 and master (commit: 2e82c9f5bd6201ed4724b26714275f4cef9df6e8).