| Summary: | [validation] Check instanceof for type inference | ||
|---|---|---|---|
| Product: | [WebTools] JSDT | Reporter: | Klaus Reimer <k> |
| Component: | General | Assignee: | Project Inbox <jsdt.javascript-inbox> |
| Status: | NEW --- | QA Contact: | Chris Jaun <cmjaun> |
| Severity: | normal | ||
| Priority: | P3 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
Build Identifier: I20110613-1736 In the following code Eclipse reports a "Type mismatch: cannot convert from A to B" warning for the "return a" statement: /** * @constructor */ function A(); /** * @constructor * @extends A */ function B(); /** * @param {A} a * @return {B} */ function test(a) { if (a instanceof B) return a; return null; } This is wrong because "a" can also be an instance of class "B" (which extends class A and is therefor a valid parameter for the function "test"). Eclipse should check at least simple if-instanceof-statements in the code to correctly determine the type of a variable. Reproducible: Always