Bug 254627 - [1.5][compiler] Eclipse does not consider an error when javac does on partially typed
Summary: [1.5][compiler] Eclipse does not consider an error when javac does on partial...
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-07 12:57 EST by Zorzella Mising name CLA
Modified: 2009-05-07 03:33 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zorzella Mising name CLA 2008-11-07 12:57:17 EST
Build ID: I20080617-2000

See simple code below. It compiles under Eclipse, but neither of the calls to "buz" pass javac. "baz" is only presented as a frame of reference, since javac and Eclipse seem to agree on that.

******************************

import java.util.List;

public class Foo {

  private static class C {}
  private static class B<T extends C> {}
  private static class A<T extends B<? extends C>> {}
  
  void bar (List<A> a) {
    baz((List)a);
    
    // Neither of these two following statements compile under javac
    buz(a);
    buz((List)a);
    
    // Side note: the following statement is correctly identified as an error
    // by Eclipse, but it does not suggest casting as a Quick Fix.
    // baz(a);
  }

  <R extends C, T extends B<R>> void baz(List<A<T>> a) {}
  <R extends C, T extends B<R>> void buz(List a) {}
  
}
Comment 1 Philipe Mulet CLA 2009-01-22 04:23:50 EST
I suspect this is a bug in javac, where the inference in JLS 15.12.2.8 doesn't properly exploit formal upper bounds. This combined with JLS 15.12.2.6 (unchecked conversion involved in invocation arguments) is likely accounting for the difference in behavior for javac between #baz(...) and #buz(...) invocations.

I believe both invocations are fine, and we should accept them.
Comment 2 Philipe Mulet CLA 2009-01-22 04:28:42 EST
Added GenericTypeTest#test1443.
Closing as invalid.
Comment 3 Philipe Mulet CLA 2009-01-22 05:02:46 EST
Re: // but it does not suggest casting as a Quick Fix.

Quickfix is only trying to fix code correctly. The quickfix you suggested would turn bad code in unsafe code; resulting into an unchecked invocation warning.
It should rather be turned into correct code, which cannot be trivially determined here.
Comment 4 Frederic Fusier CLA 2009-01-27 07:11:39 EST
Verified for 3.5M5