Bug 86463

Summary: [1.5][compiler] Compiler-Bug using generics
Product: [Eclipse Project] JDT Reporter: Ingo R. Homann <ingo.homann>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ingo R. Homann CLA 2005-02-24 08:00:48 EST
The following code will not be compiled by the sun-java-compiler, because there 
is a type-error:

class Bar<T extends java.util.List>
 {
  void bar()
  {
    T t = new java.util.ArrayList(); // BUG!!!
  }
}

The Eclipse-build-in-compiler will compile this code even without a warning!

The example above is quite unusual, but the bug is often much more disguised, 
like in the following Code:

abstract class Foo<T extends List>
 {
  abstract void foo(T t);
  void foo2()
  {
    List l = new LinkedList();
    foo(l); // BUG!!!
  }
}

class FooImpl extends Foo<ArrayList>
{
  void foo(ArrayList l)
  {
    System.out.println(l);
  }
}

The Eclipse-build-in-compiler will even compile that code!
Comment 1 Philipe Mulet CLA 2005-02-25 08:07:54 EST
Reproduced in latest.
Comment 2 Philipe Mulet CLA 2005-02-25 08:21:16 EST
Had forgotten to update RawTypeBinding#isEquivalent(...) properly.
Other rhs type were behaving ok, but raw types were comparing erasures (and
variable erases here to List which is a supertype of ArrayList).

Added GenericTypeTest#test529-530.
Comment 3 Philipe Mulet CLA 2005-02-25 08:23:49 EST
Thank for finding it.

Fixed
Comment 4 David Audel CLA 2005-03-31 09:38:15 EST
Verified in I20050330-0500