JDK-8061427 : Type variables should have lower/super bounds
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Priority: P5
  • Status: Closed
  • Resolution: Other
  • Submitted: 2004-05-26
  • Updated: 2014-12-11
  • Resolved: 2014-10-17
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Wildcards can have lower bounds.  Type variables can't.  Since wildcards are
converted to type variables with lower bounds by capture conversion the
compiler and the specification must deal with type variables with lower bounds
anyways.  Thus it appears to be a minor addition to the language to allow lower
bounds on type variables.

###@###.### 2004-05-25

Comments
The 'specification' component of the Java Bug System is for reporting technical errors and ambiguities in the text of The Java Language Specification and The JVM Specification. It is not the venue to propose new features in the Java language or JVM. Ongoing feature development is carried out in OpenJDK (http://openjdk.java.net/jeps/); corresponding enhancements to The Java Language Specification and The JVM Specification are managed through the Java Community Process (http://jcp.org/).
17-10-2014

EVALUATION See http://lampwww.epfl.ch/~odersky/ftp/local-ti.ps particularly section 3 and the last paragraph on page 9. Admitting type variables on both sides of subtype constraints can result in a set of type equations with no single best solution; consequently, type inference cannot be done using any of the existing standard algorithms. That is why type variables have only "extends" bounds. Wildcards, on the other hand, do not have to be inferred, so there is no need for this constraint. ###@###.### 2004-05-25 Yes; the key point is that wildcards, even when captured, are only used as inputs of the inference process; nothing with (only) a lower bound needs to be inferred as a result. ###@###.### 2004-05-26 I see the problem. But I do not see how it is different from the problems we have with lower bounds on wildcards during inference, e.g.: List<? super Number> s; boolean b; ... s = b ? s : s; Currently, we infer List<X> where X extends Object as the type of the conditional expression, meaning that the assignment is illegal. ###@###.### 2004-05-26
26-05-2004