Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341828 - Bad secondary error for unresolved type in instanceof expression
Summary: Bad secondary error for unresolved type in instanceof expression
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 minor (vote)
Target Milestone: 4.3 M7   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-04 13:46 EDT by Markus Keller CLA
Modified: 2013-04-30 07:38 EDT (History)
4 users (show)

See Also:


Attachments
Proposed fix (1.27 KB, patch)
2013-03-26 14:37 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-04-04 13:46:49 EDT
HEAD

The snippet below produces 2 errors:
1) FileInputStream cannot be resolved to a type
2) Incompatible conditional operand types InputStream and FileInputStream

The second error is not interesting and should not be reported as long as the RHS of the instanceof expression is not resolved.


package xy;

import java.io.InputStream;

public class Try {
    void foo(InputStream is) {
        if (is instanceof FileInputStream)
            System.out.println("Hello");
    }
}
Comment 1 Ayushman Jain CLA 2011-04-05 07:14:58 EDT
I'll take a look
Comment 2 Olivier Thomann CLA 2013-03-26 14:35:59 EDT
The fix seems trivial.
If the checkedType is not a valid binding, we should not check for checkCastTypesCompatibility(..). I'll attach a patch that can be reviewed.
Comment 3 Olivier Thomann CLA 2013-03-26 14:37:43 EDT
Created attachment 229063 [details]
Proposed fix

Regression test needs to be added and all tests need to be run. We might already have a test that returns an extra secondary error.
Comment 4 Olivier Thomann CLA 2013-03-26 14:39:12 EDT
Jay, please review.
Comment 5 Jay Arthanareeswaran CLA 2013-04-08 11:39:55 EDT
(In reply to comment #4)
> Jay, please review.

Patch looks good, will release after running the tests.
Comment 6 Jay Arthanareeswaran CLA 2013-04-08 13:12:19 EDT
Fix released here along with new tests:

http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?id=5ccdb7e247bbbd1f8f7142380f221525938bf5a9
Comment 7 shankha banerjee CLA 2013-04-30 05:10:57 EDT
Verified for 3.7 M7 using  build I20130428-2000.