Bug 220111

Summary: [1.5][compiler] Type mismatch errors on identical types; code compiles with javac
Product: [Eclipse Project] JDT Reporter: Trevor Robinson <trevor>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Karice_McIntyre, Olivier_Thomann
Version: 3.3.1   
Target Milestone: 3.4 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Tarball of source code that fails to compile none

Description Trevor Robinson CLA 2008-02-24 16:15:00 EST
Created attachment 90589 [details]
Tarball of source code that fails to compile

Build ID: M20071023-1652

Steps To Reproduce:
Untar the attached code, create a Java project for it, and note the type mismatch compile errors indicating identical types:

The method put(Sequence.Pos, Parser<Token,NodeType>.Table.State<Token>) in the type HashMap<Sequence.Pos,Parser<Token,NodeType>.Table.State<Token>> is not applicable for the arguments (Sequence.Pos, Parser<Token,NodeType>.Table.State<Token>)	sbp/src/edu/berkeley/sbp	Parser.java	line 467
Type mismatch: cannot convert from element type edu.berkeley.sbp.Parser<Token,NodeType>.Table.State<Token> to edu.berkeley.sbp.Parser<Token,NodeType>.Table.State<Token>	sbp/src/edu/berkeley/sbp	Parser.java	line 206
Type mismatch: cannot convert from element type edu.berkeley.sbp.Parser<Token,NodeType>.Table.State<Token> to edu.berkeley.sbp.Parser<Token,NodeType>.Table.State<Token>	sbp/src/edu/berkeley/sbp	Parser.java	line 240
Type mismatch: cannot convert from Parser<Token,NodeType>.Table.State<Token> to Parser<Token,NodeType>.Table.State<Token>	sbp/src/edu/berkeley/sbp	Parser.java	line 194
Type mismatch: cannot convert from Parser<Token,NodeType>.Table.State<Token> to Parser<Token,NodeType>.Table.State<Token>	sbp/src/edu/berkeley/sbp	Parser.java	line 197
Type mismatch: cannot convert from Parser<Token,NodeType>.Table.State<Token> to Parser<Token,NodeType>.Table.State<Token>	sbp/src/edu/berkeley/sbp	Parser.java	line 455

This code compiles without error under javac (JDK 1.6.0_04).

More information:
The project that fails to compile is SBP: the Scannerless Boolean Parser (http://research.cs.berkeley.edu/project/sbp/).

The latest snapshot is available using darcs: 'darcs get http://research.cs.berkeley.edu/project/sbp/edu.berkeley.sbp/'.

The license is BSD, so I'm attaching the tarball of the version the demonstrates this bug.
Comment 1 Philipe Mulet CLA 2008-02-25 13:06:23 EST
Karice - is the BSD licensed source code ok for me to look at ?
Comment 2 Philipe Mulet CLA 2008-02-25 18:19:12 EST
Got legal clearance to look at source code.
Comment 3 Philipe Mulet CLA 2008-02-25 18:42:50 EST
Simplified testcase:

public class X<Token, NodeType> {
  class Table {
    State<Token> s;
    Table() {
      this.s = new State<Token>();
    }
    class State<T> {
    }
  }
}

This should compile with no error.

Problem comes from ParameterizedSingleTypeReference which fails to convert X<Token,NodeType>.Table 
into a parameterized type.

Added GenericTypeTest#test1293-1294
Comment 4 Philipe Mulet CLA 2008-02-27 10:47:57 EST
Patch combined with https://bugs.eclipse.org/bugs/attachment.cgi?id=90846
Also added GenericTypeTest#test1296-1298
Released for 3.4M6.
Fixed
Comment 5 Philipe Mulet CLA 2008-02-28 07:35:16 EST
Released fix in 3.3.x maintenance branch (post 3.3.2)
Comment 6 Frederic Fusier CLA 2008-03-25 12:51:53 EDT
Verified for 3.4M6 using I20080324-1300.