Bug 144879

Summary: [1.5][compiler] Assignment using inferred type should be rejected
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: nbeyer
Version: 3.2   
Target Milestone: 3.2.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Philipe Mulet CLA 2006-06-01 09:23:48 EDT
Build 3.2RC6

Based on: http://forum.java.sun.com/thread.jspa?threadID=741203&tstart=0

The assignment to "it2" should be rejected:
import java.util.*;

public class X {
  static final <T, E extends T> Iterator<T> chain(Iterator<E>... it) {
	return null;
  }
  void foo3() {
	List<Integer> l1 = Arrays.asList(1, 2, 3);
	Iterator<Number> it2 = X.chain(l1.iterator(), l1.iterator());
  }
}
Comment 1 Philipe Mulet CLA 2006-06-01 09:38:49 EDT
Actually, I believe the code is valid.

Inference is performing in 2 passes.
1st pass is inferring from argument types, which is going to bind E to Integer.
Since T is still unbound, it will consider extra constraints:
1. expectation from return type as invocation is rhs of assignment:
   Iterator<T> <: Iterator<Number>
2. expectation from type parameter declared bounds
   T :> Integer

These should yield: T == Number, as this is the only one satisfying both constraints

Comment 2 Philipe Mulet CLA 2006-06-01 09:44:18 EDT
Added GenericTypeTest#test0999&1000
Comment 3 Philipe Mulet CLA 2006-06-06 04:08:24 EDT
*** Bug 145420 has been marked as a duplicate of this bug. ***