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:20:00 UTC
[jira] [Updated] (GROOVY-9948) Cannot infer the correct type in the presence of diamond operator
[ https://issues.apache.org/jira/browse/GROOVY-9948?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-9948:
------------------------------
Summary: Cannot infer the correct type in the presence of diamond operator (was: Cannot infer the right type in the presence of diamond operator)
> Cannot infer the correct 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
> Assignee: Eric Milles
> Priority: Major
> Fix For: 4.0.0-alpha-3, 3.0.11
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> 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.20.7#820007)