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/02/17 14:18:00 UTC
[jira] [Created] (GROOVY-9948) Cannot infer the right type in the
presence of diamond operator
Thodoris Sotiropoulos created GROOVY-9948:
---------------------------------------------
Summary: Cannot infer the right type in the presence of diamond operator
Key: GROOVY-9948
URL: https://issues.apache.org/jira/browse/GROOVY-9948
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Affects Versions: 3.0.7
Reporter: Thodoris Sotiropoulos
Given the following program
{code:java}
class Foo<T> {
T f;
Foo (T f) {
this.f = f;
}
}
class Main {
public static void main(String[] args) {
Foo<Integer> x = new Foo<>(1);
assert x.f > 10 == true; // does not compile
m(x);
} public static void m(Foo<Integer> x) {
assert x.f > 10 == true; // compiles fine
}
}
{code}
the type checker reports:
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Test.groovy: 11: [Static type checking] - Cannot find matching method java.lang.Object#compareTo(int). Please check if the declared type is correct and if the method exists.
@ line 11, column 14.
assert x.f > 10 == true;
^1 error
{code}
h3. Expected behaviour
I would expected that the program above compiles successfully.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)