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

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

Does canonicalName() have overloads?

0

Could you file a JIRA request?

0

Is there actually a problem?

RRS

0

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

请先登录再写评论。