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 2022/06/23 20:35:00 UTC

[jira] [Resolved] (GROOVY-10153) STC: cannot combine use-variance with bounded polymorphism

     [ https://issues.apache.org/jira/browse/GROOVY-10153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles resolved GROOVY-10153.
----------------------------------
    Fix Version/s: 5.0.0-alpha-1
       Resolution: Fixed

https://github.com/apache/groovy/commit/06dd5052edc621278cbc1114ffa593baaa3dc7b4

> STC: cannot combine use-variance with bounded polymorphism
> ----------------------------------------------------------
>
>                 Key: GROOVY-10153
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10153
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 4.0.0-alpha-3
>            Reporter: Stefanos Chaliasos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 5.0.0-alpha-1
>
>
> I have the following Groovy program.
> {code:groovy}
> @groovy.transform.TypeChecked
> class Test {
>   public void m() {
>     Foo<? super C> x = new Foo<B>();
>   }
> }
> class A {}
> class B extends A {}
> class C extends B {}
> class Foo<T extends A> {
> }
> {code}
> h2. Actual Behavior
> The program does not compile, and I get the following error.
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Test.groovy: 4: The type ? is not a valid substitute for the bounded parameter <T extends A>
>  @ line 4, column 9.
>        Foo<? super C> x = new Foo<B>();
>            ^
> 1 error
> {code}
> h2. Expected Behavior
> Compile successfully.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)