Bad "Cannot resolve..." In Call of Statically Imported Method

In a static method a call of a statically imported method is spuriously flagged as "Unable to resolve..."

Specifically, this code:


the call to canonicalName is shown in red with the tool-tip diagnostic "Cannot resolve symbol 'canonicalName'".

Changing the code to this (making the method non-static):


removes the error indication.


The code flagged as erroneous does compile (naturally) and execute as expected.


Randall Schulz

0
8 comments
Avatar
Permanently deleted user

It turns out that the missing type for the second argument was part of the problem. By supplying it, the error indication was eliminated:

Shows error:


No error indication:



RRS

0
Avatar
Permanently deleted user

Does canonicalName() have overloads?

0
Avatar
Permanently deleted user

Yes:



RRS

0
Avatar
Permanently deleted user

Could you file a JIRA request?

0
Avatar
Permanently deleted user

Is there actually a problem?

RRS

0
Avatar
Permanently deleted user

Randall Schulz wrote:

Is there actually a problem?

RRS

Surely. Resolver should correctly guess the target method based on
argument count and one matching argument.

0
Avatar
Permanently deleted user

Not exactly. The problem is actually in flagging the error in static context. It was a mistake, since Groovy does allow static methods to be injected using MOP. The request to make the resolve filter candidates that have the equal number of arguments as their parameters is really optimization that is not that easy to implement correctly: consider the case of varargs method (last parameter is of type List). And obviously it won't cover all the cases when we flag the error now though we shouldn't.

0
Avatar
Permanently deleted user

I've submitted a fix to 2.0, probably you want to port in to 1.5 as well.

0

Please sign in to leave a comment.