Bug 144879 - [1.5][compiler] Assignment using inferred type should be rejected
Summary: [1.5][compiler] Assignment using inferred type should be rejected
Status: RESOLVED INVALID
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.2.1   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 145420 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-01 09:23 EDT by Philipe Mulet CLA
Modified: 2006-06-06 04:08 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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. ***