You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/05/17 00:13:00 UTC

[jira] [Updated] (GROOVY-9963) Generic type of field is not instantiated

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

Paul King updated GROOVY-9963:
------------------------------
    Summary: Generic type of field is not instantiated  (was: Generic type of field is not istantiated)

> Generic type of field is not instantiated
> -----------------------------------------
>
>                 Key: GROOVY-9963
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9963
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>            Reporter: Thodoris Sotiropoulos
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-alpha-3, 3.0.11
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> I have the following program
> {code:java}
> class A<T> {
>   T x;
>   A(T x) {
>     this.x = x;
>   }
> }
> public class Main {
>   public static void main(String[] args) {
>     bar((new A<>("")).x);
>   }
>   public static void bar(String x) {}
> }
> {code}
> h3. Actual Behaviour
> I get the following compile-time error
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 11: [Static type checking] - Cannot find matching method Main#bar(T). Please check if the declared type is correct and if the method exists.
>  @ line 11, column 5.
>        bar((new A<>("")).x);
>        ^1 error
> {code}
> h3. Expected Behaviour
> Compile successfully
>  
> Tested on: https://github.com/apache/groovy/commit/715c34edc82261544b8715bc2253b0b3f05bdbad



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