Bug 330869 - Bogus error reported for Incompatible operand types Class<capture#2-of ? extends T> and Class<Bug.Bar>
Summary: Bogus error reported for Incompatible operand types Class<capture#2-of ? exte...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 blocker (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-22 18:53 EST by Ed Merks CLA
Modified: 2011-05-02 05:22 EDT (History)
4 users (show)

See Also:


Attachments
Patch for rollback of fix for bug 322531 (3.28 KB, patch)
2010-11-23 22:13 EST, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Merks CLA 2010-11-22 18:53:47 EST
In the example below, the "adapterType == Bar.class" test produces the error:

Incompatible operand types Class<capture#2-of ? extends T> and Class<Bug.Bar> 


package com.example.bug;

public class Bug
{
  public <T> T getAdapter(Class<? extends T> adapterType) 
  {
    T result = null;
    if (adapterType == Foo.class)
    {
      
    }
    else if (adapterType == Bar.class)
    {
      
    }
    return  result;
  }
  
  public class Foo
  {
    
  }
  
  public interface Bar
  {
    
  }
}

There's code like this in the EMF Transaction Framework, which now fails to compile.
Comment 1 Ed Merks CLA 2010-11-22 18:55:37 EST
Anthony,  this error affects TransactionalEditingDomainImpl.
Comment 2 Srikanth Sankaran CLA 2010-11-22 19:23:25 EST
Reproduced on HEAD. I'll take a look.
Comment 3 Srikanth Sankaran CLA 2010-11-22 23:26:04 EST
Released disabled junit org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest._test330869(). Will be enabled once the fix is there.
Comment 4 Olivier Thomann CLA 2010-11-22 23:31:44 EST
Seems to be related to the fix for bug 322531.
Comment 5 Srikanth Sankaran CLA 2010-11-23 06:42:06 EST
If by next I build, a suitable fix is not available,
I'll roll back the fix for bug 322531 and reopen it
rather as it is of less serious nature than the current
bug.
Comment 6 Srikanth Sankaran CLA 2010-11-23 22:13:48 EST
Created attachment 183722 [details]
Patch for rollback of fix for bug 322531

As a temporary measure, this patch

    - Short circuits the fix for bug 322531
    - Disables some tests introduced for 322531 that fail due
      to the short circuit.
    - Enabled the test added for current bug
Comment 7 Srikanth Sankaran CLA 2010-11-23 23:52:16 EST
Released the rollback patch in HEAD for 3.7 M4.
Reopened bug 322531
Comment 8 Olivier Thomann CLA 2010-12-07 11:55:24 EST
Verified using I20101207-0250 (4.1 I-build)
Comment 9 Ayushman Jain CLA 2011-05-02 05:22:52 EDT
Verified for 3.7RC0 using build I20110428-0848