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

Eric Milles updated GROOVY-9948:
--------------------------------
    Fix Version/s: 3.0.11

> 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
>            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)

Reply via email to