[
https://issues.apache.org/jira/browse/GROOVY-9963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-9963:
--------------------------------
Fix Version/s: 2.5.19
> 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, 2.5.19
>
> 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.10#820010)