Bug 86463 - [1.5][compiler] Compiler-Bug using generics
Summary: [1.5][compiler] Compiler-Bug using generics
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-24 08:00 EST by Ingo R. Homann CLA
Modified: 2005-03-31 09:38 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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