You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2023/04/15 16:25:00 UTC
[jira] [Updated] (GROOVY-10670) Cannot resolve type in the presence of use-site contravariance
[ https://issues.apache.org/jira/browse/GROOVY-10670?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10670:
---------------------------------
Priority: Minor (was: Major)
> Cannot resolve type in the presence of use-site contravariance
> --------------------------------------------------------------
>
> Key: GROOVY-10670
> URL: https://issues.apache.org/jira/browse/GROOVY-10670
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation, Static Type Checker
> Affects Versions: 4.0.3
> Reporter: Stefanos Chaliasos
> Assignee: Eric Milles
> Priority: Minor
>
> I have the following Groovy program.
>
> {code:groovy}
> 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
> }
> }
> {code}
>
> h3. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> 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
> {code}
> h3. Expected Behavior
> Compile successfully.
> h3. Comment
> Note that the equivalent Java program is accepted by javac.
> Tested against 4.0.3 and master (commit: 2e82c9f5bd6201ed4724b26714275f4cef9df6e8).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)