Community
Participate
Working Groups
Build Identifier: A method using 'this' can't be potentially static The latest beta of indigo introduces a new static analysis that detects is a method can be potentially static. But if I use 'this' in that method, it should not be tagged as potentially static. public class MethodStaticEclipseBug { public void m() { Foo.m(this); } static class Foo { static void m(MethodStaticEclipseBug bug) { // do something cool here } } } Reproducible: Always Steps to Reproduce: Type the above code in eclipse. the warning at line 3 is a false positive.
Ayush, Please take a look.
Created attachment 188029 [details] proposed fix v1.0 + regression tests This patch makes sure that the warning is not given for methods where an explicit reference to 'this' takes place. Running all tests
Srikanth, please review. Thanks!
Consistent with the rest of the code in ThisReference.java, you could have used the method isImplicitThis() instead of using its internals. In the test case comment that says "// warn" is misplaced. Otherwise it looks good.
Created attachment 188296 [details] updated patch patch incorporating above comments
Released in HEAD for 3.7M6
(In reply to comment #5) > Created attachment 188296 [details] > updated patch > > patch incorporating above comments I think that this slight variation is not cover by the proposed patch: public class EclipseImplicitThisBug { class A { } void m() { new A(); // here this is captured to create the non static inner class } } Rémi
(In reply to comment #7) > (In reply to comment #5) > > Created attachment 188296 [details] [details] > > updated patch > > > > patch incorporating above comments > > I think that this slight variation is not cover by the proposed patch: > public class EclipseImplicitThisBug { > class A { > } > > void m() { > new A(); // here this is captured to create the non static inner class > } > } > > Rémi Already reported as 335845. https://bugs.eclipse.org/bugs/show_bug.cgi?id=335845 Rémi
Verified for 3.7M6.