Community
Participate
Working Groups
Build Identifier: 20100917-0705 The warning "Indirect access to static member" sometimes wrongly reports a problem when there is none. Example: import com.google.gwt.user.client.Element; ... Element.as(body); // --> the static method as(Node) from the type Element should be accessed directly com.google.gwt.dom.client.Element.as(body); // interrestingly this works Reproducible: Always Steps to Reproduce: 1.create a class 2.import com.google.gwt.user.client.Element; 3.write a method with the line "Element.as(null);" 4.set the warning "indirect access to static member" to warning or error
Could you please provide a short test case that exhibits this issue? Thanks.
Attached you'll find a newly created eclipse project with the class as defined in "steps to reproduce"
Created attachment 180523 [details] eclipse project to show the bug
In your test case: The first method resolves to: com.google.gwt.user.client.Element.as(com.google.gwt.dom.client.Node) : com.google.gwt.dom.client.Element And the second one resolves to: com.google.gwt.dom.client.Element.as(com.google.gwt.dom.client.Node) : com.google.gwt.dom.client.Element So these are two different methods. The first Element.as(null) points to the class com.google.gwt.user.client.Element. This class inherits from com.google.gwt.dom.client.Element that defines as method as(..). So it is right that the static method is not access directly. In the second case, you are directly accessing the static method and in this case you don't get a warning. Therefore I am closing as INVALID. This works as expected.
Yes - sorry, you are absolutely right. Invalid - works as expected
Verified for 3.7M3