Bug 101831 - [1.5][compiler] Conditional expressions get confused by generic types
Summary: [1.5][compiler] Conditional expressions get confused by generic types
Status: RESOLVED DUPLICATE of bug 105531
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-27 04:30 EDT by Tobias Riemenschneider CLA
Modified: 2005-08-12 08:48 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Riemenschneider CLA 2005-06-27 04:30:02 EDT
When trying to compile the following piece of code
####
import java.util.ArrayList;

class Class<A> {
  ArrayList<A> list = new ArrayList<A>();
  ArrayList<? super A> superList = new ArrayList<A>();
  ArrayList<? extends A> extendsList = new ArrayList<A>();

  ArrayList<A> getList() {
    return true ? list : list;
  }

  ArrayList<? super A> getSuperList() {
    return true ? superList : superList;
  }

  ArrayList<? extends A> getExtendsList() {
    return true ? extendsList : extendsList;
  }
}
####
RC3 and RC4 shows for the conditional expression in getSuperList the 
error "Type mismatch: cannot convert from ArrayList<capture-of ? extends 
Object> to ArrayList<? super A>" and for the conditional expression in 
getExtendsList the error "Type mismatch: cannot convert from ArrayList<capture-
of ? extends Object> to ArrayList<? extends A>".

When compiling the same code with javac, only the method getSuperList is marked 
to be incorrect:
Class.java:14: incompatible types
found   : java.util.ArrayList<capture of ? extends java.lang.Object>
required: java.util.ArrayList<? super A>
                return true ? superList : superList;
                            ^
1 error
but the method getExtendsList compiles without errors.
Comment 1 Philipe Mulet CLA 2005-08-12 08:48:12 EDT
Added GenericTypeTest#test803

*** This bug has been marked as a duplicate of 105531 ***