Bug 216565 - [1.5][compiler] Cannot convert T to T
Summary: [1.5][compiler] Cannot convert T to T
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 216705 223334 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-01-25 06:17 EST by Olivier Lefevre CLA
Modified: 2008-03-21 16:05 EDT (History)
3 users (show)

See Also:


Attachments
Proposed patch (17.01 KB, patch)
2008-01-28 12:24 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Lefevre CLA 2008-01-25 06:17:49 EST
The following code triggers the completely non-sensical error
Type mismatch: cannot convert from List<Bug1.Foo.Sub<?>> to List<Bug1.Foo.Sub<?>>
The remedy is to fully qualify Sub, i.e., to write Foo.Sub and
not Sub.
--------------------------------------------------------------
import java.util.List;

public class Bug1 {

    static <T> List<T> asList(T[] x) { return null; }

    static interface Foo<T> {

        static interface Sub<T> extends Foo<T> {

            static List<Sub<?>> LIST = asList(ARRAY); 
        }
        
        static Sub<?>[] ARRAY = new Sub[] { };
    }
}
Comment 1 Philipe Mulet CLA 2008-01-25 07:57:33 EST
Reproduced. This is indeed a bug in our reference resolution.
Investigating
Comment 2 Philipe Mulet CLA 2008-01-25 07:59:27 EST
(reproduced with head)
Comment 3 Philipe Mulet CLA 2008-01-28 08:03:39 EST
Implementation of JLS3: 4.5.1.1 (type argument containment) did not properly handle certain wildcard situations (which btw are not mentionned in the spec).

Comment 4 Philipe Mulet CLA 2008-01-28 12:14:23 EST
Actually, previous comment is not accurate. After further investigation, it appears we had an identity issue in single name resolution; hence relying on type argument containment rules to cover for it.

This identity issue was being addressed by using qualified names.

Comment 5 Philipe Mulet CLA 2008-01-28 12:24:09 EST
Created attachment 88032 [details]
Proposed patch
Comment 6 Philipe Mulet CLA 2008-01-28 12:25:22 EST
Added GenericTypeTest#test1250-1251
Added GenericTypeTest#test1254-1266

Comment 7 Philipe Mulet CLA 2008-01-28 12:30:55 EST
*** Bug 216705 has been marked as a duplicate of this bug. ***
Comment 8 Philipe Mulet CLA 2008-01-28 14:44:37 EST
Released for 3.4M5
Fixed
Comment 9 Eric Jodet CLA 2008-02-04 06:38:09 EST
Verified for 3.4M5 using build I20080204-0010
Comment 10 Philipe Mulet CLA 2008-02-28 07:38:28 EST
Released fix in 3.3.x maintenance branch (post 3.3.2)
Comment 11 Philipe Mulet CLA 2008-03-21 16:05:09 EDT
*** Bug 223334 has been marked as a duplicate of this bug. ***