You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Sean Fitts (Jira)" <ji...@apache.org> on 2022/01/24 22:01:00 UTC
[jira] [Comment Edited] (GROOVY-10122) Wrong cast in stubs generated
[ https://issues.apache.org/jira/browse/GROOVY-10122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17481424#comment-17481424 ]
Sean Fitts edited comment on GROOVY-10122 at 1/24/22, 10:00 PM:
----------------------------------------------------------------
This is marked as fixed in 3.0.9, but I am still seeing the issue there. For example, the following class:
{code:java}
class TestGeneric<T> extends AtomicReference<T> {
TestGeneric(T value) {
super(value)
}
}
{code}
Produces the following error:
{code:java}
TestGeneric.java:15: error: incompatible types: Object cannot be converted to T
super ((java.lang.Object)null);
^
where T is a type-variable:
T extends Object declared in class TestGeneric
{code}
Note that the suggested workaround of explicitly typing the "super(value)" as "super((T)value)" does not work in this case.
was (Author: sfitts):
This is marked as fixed in 3.0.9, but I am still seeing the issue there. For example, the following class:
{code:java}
class TestGeneric<T> extends AtomicReference<T> {
TestGeneric(T value) {
super(value)
}
}
{code}
Produces the following error:
{code:java}
TestGeneric.java:15: error: incompatible types: Object cannot be converted to T
super ((java.lang.Object)null);
^
where T is a type-variable:
T extends Object declared in class TestGeneric
{code}
> Wrong cast in stubs generated
> -----------------------------
>
> Key: GROOVY-10122
> URL: https://issues.apache.org/jira/browse/GROOVY-10122
> Project: Groovy
> Issue Type: Bug
> Components: Stub generator / Joint compiler
> Affects Versions: 3.0.8
> Reporter: Daniil Ovchinnikov
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-beta-1, 3.0.9
>
> Attachments: mre.zip
>
>
> {noformat}
> $ #unzip
> $ cd mre/src
> $ groovy -version
> Groovy Version: 3.0.8 JVM: 15.0.1 Vendor: Oracle Corporation OS: Mac OS X
> $ groovyc -j JavaBase.java GroovyInheritor.groovy JavaUsage.java
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Compile error during compilation with javac.
> /var/folders/t7/26sb5vb111n3ljbmwv4s340m0000gn/T/groovy-generated--java-source12536140884342736527/GroovyInheritor.java:14: error: incompatible types: Object cannot be converted to Integer
> super((java.lang.Object)null);
> ^
> Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
> 1 error
> 1 error
> {noformat}
> The issue is not reproducible in 3.0.7.
> Same issue can be reproduced opening the directory in IntelliJ and invoking Rebuild Project.
> Related https://youtrack.jetbrains.com/issue/IDEA-270650
--
This message was sent by Atlassian Jira
(v8.20.1#820001)