groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <>
Subject [jira] [Commented] (GROOVY-7454) [Static type checking] - Reference to method is ambiguous
Date Thu, 04 Jun 2015 00:18:38 GMT


Paul King commented on GROOVY-7454:

Perhaps you can elaborate on your scenario a little more.

I tried to replicate the issue but the following compiles fine. And a little surprisingly
also runs without error.
import groovy.transform.TypeChecked

myMethod(Repository r0, CrudRepository r1, MongoRepository r2, SimpleMongoRepository r3) {
  [r0.findAll(), r1.findAll(), r2.findAll(), r3.findAll()]

assert myMethod(null, null, null, null) == [[], [], [], []]
I haven't look into the specifics of the type checker yet but its special handling of findAll
for Object and null seems to kick in here even for the marker interface. Using {{@CompileStatic}}
causes NPE for all the calls but I presume that isn't what you are concerned about.

If I supply null as the parameter to one of the interface {{findAll}} calls, e.g. {{r2.findAll(null)}}
I get NPE errors at runtime from the {{DGM#findAll}} method. This is indicating DGM methods
have precedence over interface methods and possibly explains why the static compiler isn't

If I suppler null as the parameter to the class, e.g. {{r3.findAll(null)}} I get:
[Static type checking] - Reference to method is ambiguous.
but that is to be expected. If I supply a cast I get a NPE.

> [Static type checking] - Reference to method is ambiguous
> ---------------------------------------------------------
>                 Key: GROOVY-7454
>                 URL:
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.3
>            Reporter: Christopher Smith
>            Assignee: C├ędric Champeau
> This issue has a number of seeming duplicates marked as "fixed", but I'm reliably seeing
it in 2.4.3 when calling `findAll()` on any Spring `CrudRepository`:
> {code}
> Groovy:[Static type checking] - Reference to method is ambiguous. Cannot choose between
[java.util.List <T>,
java.util.List <T>]
> {code}
> No idea whether this is triggered in particular by the name of the method, which Groovy
defines on {{Object}}.

This message was sent by Atlassian JIRA

View raw message