Community
Participate
Working Groups
I20080812-0800 Content assist after 'instanceof X' should also propose members of type X in assignments or local variable declarations: void m(CharSequence cs) { String lower= null; if (cs instanceof String) { cs.to // good } if (cs instanceof String) { return cs.to // good } if (cs instanceof String) { lower= cs.to // bad } if (cs instanceof String) { String low= cs.to // bad } } In the 'good' examples, e.g. String#toLowerCase() is proposed. In the 'bad' examples, only methods from CharSequence and Object are proposed. [BTW: After 'cs.tol', completion currently fails if common prefix completion is enabled, see bug 244818.]
Ayush, Please take a look. Why is this not a duplicate of bug# 287939 ? The second bad case cited by Markus works ok on HEAD while the first one is still broken.
(In reply to comment #1) > Ayush, Please take a look. Why is this not a duplicate of > bug# 287939 ? The second bad case cited by Markus works ok > on HEAD while the first one is still broken. Both cases work correctly using 3.6M6. This can be safely closed as a dup of bug 287939.
By itself, the first of the 'bad' examples works fine in I20100413-1521. But if you take the complete example from comment 0, it still doesn't work. Can we keep this bug for that problem? The second of the 'bad' examples still works fine.
This will be handled along with bug 304006. Added in bug 304005 comment 5 *** This bug has been marked as a duplicate of bug 304006 ***
Correction in above comment Added in bug 304006 comment 5
Ayush, Since this test case has no connection to the tests you have in bug# 304006 comment#0, please provide the fix here rather than using bug#304006 as an umbrella bug for all instanceof completion issues. This will simplify code review, verification and "software archeology" in the future should the need arise.
Created attachment 165415 [details] proposed fix v1.0 + updated regression tests Here because of the existing errors in the compilation unit prior to where the completion is requested, the expressionStack doesnt contain the instanceof expression enclosing the 3rd bad case. This is because the stack is reset during recovery, which in this case starts from after the if (cs instanceof String) statement. So in this case we have to rely on the elementObjectInfoStack to find the instanceof expression. The uncertainty in the recovery mode prevents us from relying on any of the two stacks entirely.
(In reply to comment #7) > Created an attachment (id=165415) [details] > proposed fix v1.0 + updated regression tests Patch looks good. Released to HEAD for 3.6M7
Verified for 3.6M7 using build I20100424-2000