Bug 263633 - [1.5][compiler] Invalid type mismatch for after generic method inference
Summary: [1.5][compiler] Invalid type mismatch for after generic method inference
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-04 09:01 EST by Philipe Mulet CLA
Modified: 2009-03-10 10:25 EDT (History)
6 users (show)

See Also:


Attachments
Proposed patch (21.83 KB, patch)
2009-02-04 12:52 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 Philipe Mulet CLA 2009-02-04 09:01:20 EST
Build 3.5M5

This is a regression over 3.5M4, identified by Ed Merks.
The following code should compile clear (simple testcase extracted from QVT codebase).

public abstract class X implements Visitable {
  public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v) {
    return null;
  }
  public <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept2(U v) {
    if (v == null)
      return this.accept(v);
    else 
      return this.<T, U> accept(v);
  }
}

interface Visitable {
  <T, U extends Visitor<T, ?, ?, ?, ?, ?, ?, ?, ?, ?>> T accept(U v);
}

interface Visitor<T, C, O, P, EL, PM, S, COA, SSA, CT> {
}
Comment 1 Philipe Mulet CLA 2009-02-04 09:34:24 EST
Problem comes from better implementation for 15.12.2.6 released during 3.5M5.
Inference is more sensitive to unchecked conversions, and does perform erasure conversion in presence of unchecked argument types...
BUT in this case, it should not occur. However, the method lookup tiebreak code is triggering more generic inference, and performs indirectly a side effect on the original invocation site.
Comment 2 Kent Johnson CLA 2009-02-04 10:39:43 EST
Philippe - why does X being an abstract class cause the error ?

We do not report an error with this case:

// abstract class X implements I {
class X implements I {
	public <T1, U1 extends Visitor<T1>> T1 accept(U1 v) { return null; }
	<T2, U2 extends Visitor<T2>> void test(U2 v) {
		T2 t = this.accept(v); // type mismatch error if X is abstract
	}
}
interface I {
	<T3, U3 extends Visitor<T3>> T3 accept(U3 v);
}
interface Visitor<T4> {}


But we do report the type mismatch once X is made abstract.
Comment 3 Philipe Mulet CLA 2009-02-04 12:35:17 EST
As soon as we detect the need for a tiebreak, like with abstract super types etc... we may run into this bug, as it may perform more than one inference on same invocation site (msg send) and possible pollute it with transient tiebreak/raw method information.
Comment 4 Philipe Mulet CLA 2009-02-04 12:52:23 EST
Created attachment 124700 [details]
Proposed patch
Comment 5 Philipe Mulet CLA 2009-02-04 13:00:51 EST
Sent bin patch to Ed for testing.
Comment 6 Philipe Mulet CLA 2009-02-05 04:39:34 EST
Improvements near JLS 15.12.2.6 were captured by bug 258798.

Released for 3.5M6.
Fixed
Comment 7 Jerome Lanneluc CLA 2009-02-05 05:30:35 EST
A binary patch is available at: 
http://www.eclipse.org/jdt/core/patches/org.eclipse.jdt.core_3.5.0.fix263633.jar
?

To install on 3.5M5:
1. Shut down Eclipse
2. Rename eclipse/plugins/org.eclipse.jdt.core_3.5.0.v_936.jar 
   to eclipse/plugins/org.eclipse.jdt.core_3.5.0.v_936.jar.disabled
3. Download org.eclipse.jdt.core_3.5.0.fix263633.jar (from link above) to
   eclipse/plugins
4. Rename eclipse/plugins/org.eclipse.jdt.core_3.5.0.fix263633.jar
   to eclipse/plugins/org.eclipse.jdt.core_3.5.0.v_936.jar
5. Restart Eclipse
Comment 8 Philipe Mulet CLA 2009-02-05 09:17:18 EST
These steps will not work if launching Eclipse with '-clean'... but it shouldn't be necessary nowadays anyway.
Comment 9 Ed Merks CLA 2009-02-05 09:26:23 EST
Yes, this fix eliminate the compilation problems in QVT.
Comment 10 Kent Johnson CLA 2009-03-10 10:25:34 EDT
Verified for 3.5M6 using I20090310-0100