Inference question
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Feb 5 06:41:44 PST 2013
On 05/02/13 13:12, Maurizio Cimadamore wrote:
> This is just a bug.
Fixed.
Maurizio
>
> Maurizio
>
> On 05/02/13 12:28, Boaz Nahum wrote:
>> class TypeInterfrer3 {
>>
>>
>> private interface TKey<T> {
>>
>> }
>>
>> public static <TK extends TKey<?>> TK createKey(TK relativeKey) {
>> return null;
>> }
>>
>>
>> static <T> T getValue(TKey<T> key) {
>> return null;
>> }
>>
>>
>> public static void main(String[] args) {
>>
>>
>> TKey<Integer> ki = new TKey<Integer>() {}
>>
>>
>>
>> //*OK*
>> int i = getValue(createKey(ki));
>>
>> //*OK*
>> double d0 = getValue(ki);
>>
>>
>> //*OK*
>> double d1 = getValue(TypeInterfrer3.<TKey<Integer>>createKey(ki));
>>
>> //*OK*
>> double d2 = (int)getValue(createKey(ki));
>>
>> * // Fails:
>> // java: incompatible types: inference variable T has incompatible
>> bounds
>> // equality constraints:java.lang.Integer
>> /// upper bounds:java.lang.Double, java.lang.Object*
>> double d3 = getValue(createKey(ki));
>>
>>
>> }
>>
>>
>> }
>
More information about the lambda-dev
mailing list