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 2021/03/21 14:38:00 UTC
[jira] [Resolved] (GROOVY-7306) Invalid stub generated for a
constructor using a generic bounded parameter
[ https://issues.apache.org/jira/browse/GROOVY-7306?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-7306.
---------------------------------
Fix Version/s: 4.0.0-alpha-3
Resolution: Fixed
> Invalid stub generated for a constructor using a generic bounded parameter
> --------------------------------------------------------------------------
>
> Key: GROOVY-7306
> URL: https://issues.apache.org/jira/browse/GROOVY-7306
> Project: Groovy
> Issue Type: Bug
> Components: Stub generator / Joint compiler
> Affects Versions: 2.4.0, 2.4.1
> Reporter: Frank Pavageau
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-alpha-3
>
> Attachments: generic-superclass-stub.tar.gz
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Given the 2 following classes:
> {code}
> class A<T extends Number> {
> final T value
> A(T value) {
> this.value = value
> }
> }
> {code}
> and
> {code}
> class B extends A<Integer> {
> B(Integer value) {
> super(value)
> }
> }
> {code}
> the generated stub for B does not compile, as the constructor parameter is cast to the bounded type instead of the actual type:
> {code}
> public class B
> extends A<java.lang.Integer> {
> ;
> public B
> (java.lang.Integer value) {
> super ((java.lang.Number)null);
> }
> // ...
> }
> {code}
> The error returned by the compiler is:
> {noformat}
> target/generated-sources/groovy-stubs/main/B.java:[13,1] constructor A in class A<T> cannot be applied to given types;
> required: java.lang.Integer
> found: java.lang.Number
> reason: actual argument java.lang.Number cannot be converted to java.lang.Integer by method invocation conversion
> {noformat}
> I've attached a test case, which is also available on [Github|https://github.com/fpavageau/generic-superclass-stub].
--
This message was sent by Atlassian Jira
(v8.3.4#803005)