Community
Participate
Working Groups
HEAD A reference to Outer.this should be a compile error in a static context, even if the instance is not actually used because a static method is called: package p; public class Outer { public static void bar() { new Object() { public void foo() { Outer.this.bar();// Only warns about non-static access to bar, // but 'Foo.this' should be a compile error. getOuter().bar();// Correct compile error. } }.toString(); } Outer getOuter() { return new Outer(); } }
I'll take a look.
I think we have two issues there. 1) We don't report an error for this case until code generation. This seems to be done on purpose in the QualifiedThisReference resolveType(..) code. 2) In this case we don't report an error, because we report it only if we generate the code with valueRequired set to true. See org.eclipse.jdt.internal.compiler.ast.MessageSend line 149. One way to fix (2) would be to pass valueRequired set to true and pop the value. This would report the error if there is not a second error in the same method. (1) means that this error is not reported as long as there is already another error in the same method. When a second error is reported, the code generation for this method is never reached as it is converted to a problem method (when compiled with -proceedOnError) or simply dropped. Srikanth, if we want to improve this, we should report the error inside the resolveType(..) method or find a better location to do so. To fix (1), we need to find a location inside the type resolution. For (2), if we fix (1), then there is no more issue. If we don't want to fix (1),l then maybe we should resolve the emulation path regardless of the value required flag. I'll let you consider these two options. Thanks.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.