History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEADEV-23801
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Normal Normal
Assignee: Alexey Kudravtsev
Reporter: Matthias Ernst
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
IDEA: Development

good code red: inheriting from raw type: "attempting to use incompatible return type"

Created: 23 Nov 07 23:25   Updated: 11 Dec 07 17:28
Component/s: Editor. Error Highlighting
Fix Version/s: Diana 8243, Selena 7.0.3

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 7,364
Fixed in build: 7,599


 Description  « Hide
package java.raw;

import java.util.Collections;
import java.util.List;

public class ExtendsRaw {
public static class Base<T> {
public List<T> elements() { return null; }
}

public static class Derived<T> extends Base<T> {}

public static class MostDerived extends Derived {
public List<MostDerived> elements() { return Collections.emptyList(); }
}
}

MostDerived#elements is flagged red (incompatible return type) but compiles fine. I believe it's good according to the JLS.

Interestingly, if MostDerived inherits directly from Base, the error flag goes away.



 All   Comments   Work Log   Change History      Sort Order:
Eugene Vigdorchik - 25 Nov 07 14:33
What makes you believe javac is right and IDEA is wrong here?

Matthias Ernst - 25 Nov 07 15:26
> What makes you believe javac is right and IDEA is wrong here?

Three indications:
1. IDEA behaves differently for "MostDerived extends Derived extends Base" (red) and "MostDerived extends Base" (green). I can't think of an explanation for that other than there's a bug.
2. It also compiles fine when I switch to eclipse compiler.
3. From JLS 4.8 "Raw Types" I read that the inherited method "elements" from Base has the raw return type "List" that is overridden with "List<MostDerived>". According to 4.10.2, List<MostDerived> is a subtype of the raw type List, so the overriding is correct.