Summary: | [compiler] compiler wrongly suggests to add a static qualifier to a method | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Philippe Coucaud <phil_fj12> | ||||||
Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | Olivier_Thomann, satyam.kandula | ||||||
Version: | 3.7 | Flags: | satyam.kandula:
review+
|
||||||
Target Milestone: | 3.7 M6 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows 7 | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Philippe Coucaud
2011-01-31 08:54:15 EST
Created attachment 188036 [details]
proposed fix v1.0 + regression tests
Allocation of a (non-static) member typewithout an enclosing instance of a parent type is done via AllocationExpression, while with an enclosing instance is done via QualifiedAllocationExpression. This patch adds a check in AllocationExpression#analyseCode(..) to reset the static flag for a method if an allocation expression is encountered for a non-static member type.
All tests pass. Satyam, please review. Thanks! Ayush, The following test fails with the patch. public class SuperTest { class Bar {} } public class Test extends SuperTest{ private void foo() { new Bar(); } } Created attachment 188147 [details]
proposed fix v1.1 + regression tests
Here's the updated fix. I was using the wrong bits - ASTNode.IsMemberType bits, whereas I should've used TagBits.IsMemberType, since i'm checking the binding bits and not the AST node bits.
Added another test to take care of this.
+1. The patch looks good for me. Released in HEAD for 3.7M6 Verified for 3.7M6. |