Summary: | [compiler] Assignment with no effect undetected | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Pascal Rapicault <pascal> | ||||||||
Component: | Core | Assignee: | Maxime Daniel <maxime_daniel> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | normal | ||||||||||
Priority: | P3 | CC: | Olivier_Thomann | ||||||||
Version: | 3.3 | ||||||||||
Target Milestone: | 3.4 M3 | ||||||||||
Hardware: | PC | ||||||||||
OS: | Windows XP | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
Pascal Rapicault
2007-08-21 15:55:29 EDT
Created attachment 76783 [details]
Proposed fix
Philippe, please review.
This patch reports an assignment with no effect when the qualified name simply refers to a static field using ClassName.FieldName.
Created attachment 76784 [details]
Regression tests
What about a situation where the qualified name has the package prefix ? e.g. some.package.ClassName.field The proposed patch works fine. package p; public class X { public static Object context; public void start(Object ctx) throws Exception { p.X.context = context; } } ---------- 1. WARNING in D:\tests_sources\p\X.java (at line 6) p.X.context = context; ^^^^^^^^^^^^^^^^^^^^^ The assignment to variable context has no effect ---------- Looks good to me. Maxime pls proceed. Fix is OK in that it addresses most common cases involving static fields. Added a few more tests that check variations (package, inner class, swapping the lhs and the rhs) and document a limitation (there are cases for which a static analysis could prove that the runtime type of a variable equates a defined one, in which case the access to the static fields of the said variable would provably point to a well defined field, and we could report additional warnings - see AssignmentTest#48, which is inactive). Created attachment 80549 [details]
Fix + test cases
Fixed a typo in comments and added more tests.
Released for 3.4 M3 Verified for 3.4M3 using I20071029-0010 build. |