Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 98364

Summary: [1.5][compiler] Compiler allowing invalid generic interface inheritance
Product: [Eclipse Project] JDT Reporter: Ian Graham <igraham>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: kent_johnson
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Ian Graham CLA 2005-06-03 15:48:00 EDT
The following code causes an error in Sun's javac, but Eclipse 3.1RC1 is 
allowing it.  The problem is that for IntegerListIterator declaration to be 
valid, the IntegerIterator should be required to extend Iterator<Integer> as 
well.

import java.util.Iterator;
import java.util.ListIterator;

interface IntegerIterator extends Iterator {
    public abstract int nextInt();
}
interface IntegerListIterator extends ListIterator<Integer>, IntegerIterator {
    public abstract int previousInt();
}
Comment 1 Ian Graham CLA 2005-06-03 16:10:15 EDT
The following illustrates the problem more simply, and should be illegal:

import java.util.*;
interface IntegerListIterator extends ListIterator<Integer>, Iterator {}
Comment 2 Philipe Mulet CLA 2005-06-06 07:32:01 EDT
Suspect the raw type is tolerated by mistake.
Comment 3 Philipe Mulet CLA 2005-06-06 07:34:33 EDT
Interestingly we correctly catch this error case:
interface Foo<T> {}
class XSuper implements Foo {}
public class X extends XSuper implements Foo<Integer> {}
Comment 4 Philipe Mulet CLA 2005-06-06 07:35:49 EDT
Problem only occurs when checking interfaces.
Comment 5 Philipe Mulet CLA 2005-06-06 08:01:11 EDT
Problem comes from the fact that when resolving superinterfaces, the source type
isn't yet connected to its direct superinterfaces. Thus it is missing part of
the types to check. These obtained through superclass are fine.

Added GenericTypeTest#test719.
Comment 6 Philipe Mulet CLA 2005-06-06 08:01:23 EDT
Fixed
Comment 7 Frederic Fusier CLA 2005-06-07 11:34:33 EDT
Verified for 3.1 RC2 using build N20050607-0010 + JDT/Core HEAD
Comment 8 David Audel CLA 2005-06-10 11:49:22 EDT
Verified for 3.1 RC2 using build I20050610-0010