Bug 112268 - [1.5][compiler] Type mismatch introduced in 3.1.1
Summary: [1.5][compiler] Type mismatch introduced in 3.1.1
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.1.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 112595 114997 123390 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-11 19:38 EDT by Robert Konigsberg CLA
Modified: 2006-01-11 07:16 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Konigsberg CLA 2005-10-11 19:38:19 EDT
The following class does not compile; it yields a "Type mismatch: cannot convert
from List<Object> to List<? extends Comparator>" error.
---
import java.util.*;

public class Foo2 {

  List<? extends Comparator> getFoo() {
    return Collections.emptyList();
  }
}
---
This also occurs on Windows XP 3.1.1.
Comment 1 Philipe Mulet CLA 2005-10-12 09:11:18 EDT
Consequence of fix for bug 107079.
Wonder if we should force capture before inference here, or allow inferring from
wildcards; but then this would contradict spec and break bug 107079 again.

Note that all return type inference scenarii are broken in similar fashion:

import java.util.*;
public class X {
  List<? extends Comparator> bar() {
	  List<? extends Comparator> l = foo();
	  return foo();
  }
  <T> List<T> foo() {
	  return null;
  }
}
Comment 2 Philipe Mulet CLA 2005-10-13 04:24:49 EDT
Actually, I had missed one inference rule from the spec (A >> F, where A=G<?
extends/super V> >> G<U>) on p. 459.

Added support and GenericTypeTest#test841.
Fixed, will backport to 3.1 maintenance stream.
Comment 3 Philipe Mulet CLA 2005-10-13 04:54:05 EDT
Thanks Tim for the pointer in spec.
Comment 4 Philipe Mulet CLA 2005-10-13 04:55:39 EDT
Note that in 3.1.0, code was accepted, but slightly incorrectly in the sense
that T got inferred to '? extends Comparator', where it is now inferred to be
'Comparator'.
Comment 5 Philipe Mulet CLA 2005-10-13 09:05:43 EDT
Note: workaround is to write:

import java.util.*;

public class Foo2 {

  List<? extends Comparator> getFoo() {
    return Collections.<Comparator>emptyList();
  }
}
Comment 6 Robert Konigsberg CLA 2005-10-13 10:05:46 EDT
Thanks for the immediate response. When (how?) do I get the maintenance release?
Comment 7 Philipe Mulet CLA 2005-10-13 10:18:32 EDT
3.1.2 is scheduled early next year officially (details on eclipse roadmap).
Now, we can post a patch on JDT/Core web page so you do not need to wait that long.
Comment 8 Robert Konigsberg CLA 2005-10-13 10:30:14 EDT
Perfect! Thanks again Philippe (and thanson too!)
Comment 9 Philipe Mulet CLA 2005-10-13 10:36:31 EDT
Olivier - pls produce a preview of our 3.1.2 contribution at earliest convenience.
Comment 10 Philipe Mulet CLA 2005-10-14 08:40:08 EDT
*** Bug 112595 has been marked as a duplicate of this bug. ***
Comment 11 Olivier Thomann CLA 2005-10-14 09:37:28 EDT
You can get the jdt/core patch on the jdt/core web page to get it fixed before
3.1.2 is out.
See http://www.eclipse.org/jdt/core/r3.1/main.html#updates
Comment 12 Philipe Mulet CLA 2005-11-03 18:02:38 EST
*** Bug 114997 has been marked as a duplicate of this bug. ***
Comment 13 Olivier Thomann CLA 2005-12-13 10:11:42 EST
Verified for 3.2M4 in I20051212-2000
Comment 14 Olivier Thomann CLA 2006-01-09 11:02:53 EST
Verified for 3.1.2 in M20060109-0800.
Comment 15 Philipe Mulet CLA 2006-01-11 07:16:32 EST
*** Bug 123390 has been marked as a duplicate of this bug. ***