You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/03/03 21:35:00 UTC
[jira] [Updated] (GROOVY-9963) Generic type of field is not
istantiated
[ https://issues.apache.org/jira/browse/GROOVY-9963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thodoris Sotiropoulos updated GROOVY-9963:
------------------------------------------
Description:
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
was:
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
> Generic type of field is not istantiated
> ----------------------------------------
>
> Key: GROOVY-9963
> URL: https://issues.apache.org/jira/browse/GROOVY-9963
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Priority: Major
>
> 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.3.4#803005)