Bug 159851 - [1.5] [compiler] Eclipse compiler fails to report type parameter bounds errors when generic instance is a type argument
Summary: [1.5] [compiler] Eclipse compiler fails to report type parameter bounds error...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-05 05:42 EDT by Sasha Kogan CLA
Modified: 2009-04-29 11:17 EDT (History)
3 users (show)

See Also:


Attachments
Proposed patch and testcase (3.67 KB, patch)
2009-03-30 14:14 EDT, Kent Johnson CLA
no flags Details | Diff
Proposed patch and testcase (9.63 KB, patch)
2009-03-31 16:35 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sasha Kogan CLA 2006-10-05 05:42:14 EDT
public class BaseClass {
}

public class GenClass<T extends BaseClass> {
}

public class EclipseCompilerTest <T extends ArrayList<GenClass<Integer>>> extends TreeMap<Integer, GenClass<String>> {

}

The classes above pass compilation with the Eclipse compiler, although there're illegal GenClass<Integer> and GenClass<String> instantiations. Sun's 1.5.0_04 reports the errors as expected.
Comment 1 Philipe Mulet CLA 2006-10-05 15:56:48 EDT
Reproduced... strange.
Comment 2 Philipe Mulet CLA 2006-10-05 16:02:56 EDT
Actually our boundcheck is not strict enough for type arguments at depth > 1. I think this is something which has changed under us, and we should realign.
Comment 3 Walter Laan CLA 2007-03-29 03:51:37 EDT
We encountered this bug with :

public class GenericClass<T extends Number> {
}

public class GenericClassTwo<T> {
}

public class EclipseCompilerTest<T> extends GenericClassTwo<GenericClass<T>> {
}

with 1.6 javac:
EclispeCompilerTest.java:2: type parameter T is not within its bound
public class EclispeCompilerTest<T> extends GenericClassTwo<GenericClass<T>> {
               
No error or warning with Eclipse 3.2.1 or 3.2.2                                                         
Comment 4 Maxime Daniel CLA 2008-06-09 08:20:54 EDT
The following might be a variant of the same issue (javac reports an error on line  marked 1):

class X<T> {
  static class XX<U> extends X<U> {
    class XXX<V extends I<U>> extends XY<V> { // 1
    }
  }
  class XY<W extends I<T>> {
  }
}
interface I<T> {
}
Comment 5 Kent Johnson CLA 2009-03-30 14:14:45 EDT
Created attachment 130282 [details]
Proposed patch and testcase

Philippe - let me know if this patch works for you & I'll release it

It passes all of our existing tests
Comment 6 Kent Johnson CLA 2009-03-31 16:35:15 EDT
Created attachment 130461 [details]
Proposed patch and testcase

This patch remembers each TypeRef that we delayed the boundsCheck & does it after the hierarchy is attached
Comment 7 Kent Johnson CLA 2009-04-01 11:13:14 EDT
Fix and test released for 3.5M7
Comment 8 Kent Johnson CLA 2009-04-01 11:24:13 EDT
Forgot to mark as fixed
Comment 9 Jay Arthanareeswaran CLA 2009-04-29 05:53:52 EDT
Kent,

The compiler doesn't report any problem on the code given in the comment #4. Should we treat this as a separate test case? What's your opinion on this one?

Jay
Comment 10 Kent Johnson CLA 2009-04-29 10:36:49 EDT
b55 of javac 7.0 also doesn't report an error on the case in comment #4

I believe we are correct for this case.
Comment 11 David Audel CLA 2009-04-29 11:17:42 EDT
Verified for 3.5M7 using I20090428-0100