Bug 163262 - [1.5][compiler] Type mismatch: cannot convert from List<A> to List<A>
Summary: [1.5][compiler] Type mismatch: cannot convert from List<A> to List<A>
Status: RESOLVED DUPLICATE of bug 122610
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-02 16:24 EST by Patrik Beno CLA
Modified: 2006-11-07 13:00 EST (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 Patrik Beno CLA 2006-11-02 16:24:36 EST
JavaC (1.5) compiles this with no problem, Eclipse compiler does not (embedded eclipse compiler in IDEA 6.0.1, not sure what version exactly it is)

==[ ERROR ]==
Information:Compilation completed with 1 error and 0 warnings
Information:1 error
Information:0 warnings
src\com\sun\tools\javac\util\List.java
    Error:Error:line (379)Type mismatch: cannot convert from List<A> to List<A>
--

Source file is from Mustang (JDK6) sources, build 104, if I am not mistaken
Following is the critical source fragment:

    @Override
    public Iterator<A> iterator() {
        if (tail == null)
            return emptyIterator();
	return new Iterator<A>() {
	    List<A> elems = List.this; // <========= line 379
	    public boolean hasNext() {
		return elems.tail != null;
	    }
	    public A next() {
                if (elems.tail == null)
                    throw new NoSuchElementException();
		A result = elems.head;
		elems = elems.tail;
		return result;
	    }
	    public void remove() {
		throw new UnsupportedOperationException();
	    }
	};
    }
Comment 1 Olivier Thomann CLA 2006-11-03 07:58:12 EST
I'll see if we can reproduce with HEAD.
Comment 2 Olivier Thomann CLA 2006-11-03 13:57:35 EST
I don't have access to the source code of this class.
Would it be possible for you to provide a small test case not related to Sun code?
Comment 3 Patrik Beno CLA 2006-11-04 08:54:40 EST
(In reply to comment #2)
> Would it be possible for you to provide a small test case not related to Sun
> code?
> 

here you are:

public class Bug<A> {
   void bug() {
      new Runnable() {
         public void run() {
            Bug<A> bug = Bug.this;
         }
      };
   }
}
Comment 4 Patrik Beno CLA 2006-11-04 08:57:03 EST
(In reply to comment #3)
> (In reply to comment #2)
> > Would it be possible for you to provide a small test case not related to Sun
> > code?
> > 
> 

or even simple:

public class Bug<A> {
   Bug<A> reproduce() {
      return Bug.this;
   }
}
Comment 5 Olivier Thomann CLA 2006-11-06 17:15:42 EST
Are you sure your test cases don't compile with your version?
I tried with HEAD, 3.2.0 and 3.2.1 and I could not reproduce.
Could you please provide your compiler settings?
Comment 6 Patrik Beno CLA 2006-11-07 11:03:48 EST
Again, it is an eclipse compiler embedded in IDEA 6.0.1. I inspected bundled org.eclipse.jdt.core.jar and its manifest says:

Bundle-Version: 3.2.0.v_631

Is this what you need?
Comment 7 Olivier Thomann CLA 2006-11-07 12:01:58 EST
Yes, thank you.
This means IDEA 6.01 is using 3.2M4 Eclipse compiler.

Closing as a duplicate of bug 122610. If possible, you can try to patch this jar with the one from Eclipse 3.2.0 (v_671).
I'll add specific regression test for this one.
Comment 8 Olivier Thomann CLA 2006-11-07 12:02:22 EST

*** This bug has been marked as a duplicate of 122610 ***
Comment 9 Olivier Thomann CLA 2006-11-07 13:00:34 EST
Reproduced with v_631 and checked that it is fixed with v_632.
Added regression tests org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1069/1070