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/04/10 22:17:00 UTC
[jira] [Resolved] (GROOVY-10011) Combining flow typing and type
argument inference does not work as expected
[ https://issues.apache.org/jira/browse/GROOVY-10011?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-10011.
----------------------------------
Fix Version/s: 4.0.0-alpha-3
Resolution: Fixed
> Combining flow typing and type argument inference does not work as expected
> ---------------------------------------------------------------------------
>
> Key: GROOVY-10011
> URL: https://issues.apache.org/jira/browse/GROOVY-10011
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-alpha-3
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> I have the following program
> {code:java}
> class A<T> {
> T f;
> public A(T f) {
> this.f = f;
> }
> }
> class Foo {}
> class Bar extends Foo {}
> public class Main {
> public static void bar(Foo x) {
> if (x instanceof Bar) {
> A<Bar> a = new A<>(x)
> }
> }
> }
> {code}
> h3. Actual Behavior
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 15: [Static type checking] - Incompatible generic argument types. Cannot assign A <Foo> to: A <Bar>
> @ line 15, column 18.
> A<Bar> a = new A<>(x)
> ^1 error
> {code}
> h3. Expected Behavior
> Compile successfully
>
> Tested against https://github.com/apache/groovy/commit/359be2b662be646d2d59db8b999412691891231d
--
This message was sent by Atlassian Jira
(v8.3.4#803005)