Bug 84496 - [1.5][compiler] Capture Conversion not correctly implemented
Summary: [1.5][compiler] Capture Conversion not correctly implemented
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 91017 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-02-04 18:36 EST by Tim Hanson CLA
Modified: 2005-05-11 10:13 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (32.71 KB, patch)
2005-02-17 19:38 EST, Tim Hanson CLA
no flags Details | Diff
New tests for patch (1.81 KB, patch)
2005-02-18 14:04 EST, Tim Hanson CLA
no flags Details | Diff
Individual patch for DOM AST ITypeBinding (51.68 KB, patch)
2005-04-19 18:17 EDT, Philipe Mulet CLA
no flags Details | Diff
Individual patch for model Signature (7.77 KB, patch)
2005-04-19 18:24 EDT, Philipe Mulet CLA
no flags Details | Diff
Individual patch for DOM AST ITypeBinding (9.55 KB, patch)
2005-04-20 09:05 EDT, Jim des Rivieres CLA
no flags Details | Diff
Individual patch for DOM AST ITypeBinding (53.34 KB, patch)
2005-04-20 09:21 EDT, Jim des Rivieres CLA
no flags Details | Diff
Individual patch for model Signature (8.28 KB, patch)
2005-04-20 09:36 EDT, Jim des Rivieres CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Hanson CLA 2005-02-04 18:36:48 EST
The following program should not compile. The assignment should fail with an
error message like "Inconvertible types. Found X.Bar<capture of ?>, required
X.Bar<capture of ?>."



class X {
    public static void main(String[] args) {
        Foo<?> f1 = new Foo<Integer>();
        f1.bar = f1.bar;
    }
    static class Foo<T> {
       Bar<T> bar = new Bar<T>();
    }
    static class Bar<T> {
        T t;
    }
}
Comment 1 Tim Hanson CLA 2005-02-17 19:38:09 EST
Created attachment 18084 [details]
Proposed patch

I ran the JCK and had 27 failures. None appeared related to my bug.

I ran the org.eclipse.jdt.core.tests.compiler test suite. There were numerous
spurious differences due to textual changes from "?" to "capture of ?". I
believe all failures are now either correct with the patch (ie, a false
failure), pre-existing, or spurious.
Comment 2 Philipe Mulet CLA 2005-02-18 04:21:23 EST
Thank you much. Will look into integrating it soon.
BTW, which version is this based upon ?
Would you also contribute some JUnit tests demonstrating its improved behavior ?
Comment 3 Tim Hanson CLA 2005-02-18 13:29:28 EST
Is there some easy way of turning the compiler output into the expected text for
the diagnostic message? The commandline compiler seems to format the output
slightly differently than when running through JUnit. I can't seem to get my
test to pass. It's complaining about diffs in what I can only assume is whitespace.

The patch is based on a sync to the head revision about two weeks ago.
Comment 4 Tim Hanson CLA 2005-02-18 14:04:21 EST
Created attachment 18107 [details]
New tests for patch

I've added a two tests in GenericTypeTests.
Comment 5 Philipe Mulet CLA 2005-02-18 16:06:22 EST
You probably figured it out, but I will explain anyway...
Usually you write the test, without filling the expected output.
You run it, and then it fails and dumps in console what it did expect to obtain.
You can then simply cut&paste back into the testcase after checking it is ok.
Comment 6 Philipe Mulet CLA 2005-04-08 07:30:33 EDT
Added GenericTypeTest#test488-489
Comment 7 Philipe Mulet CLA 2005-04-11 14:46:19 EDT
Added attached tests as GenericTypeTest#test581-582.
Comment 8 Philipe Mulet CLA 2005-04-11 15:03:16 EDT
*** Bug 91017 has been marked as a duplicate of this bug. ***
Comment 9 Philipe Mulet CLA 2005-04-19 18:17:05 EDT
Created attachment 20088 [details]
Individual patch for DOM AST ITypeBinding

(apply to DOM AST ITypeBinding unit)

This patch previews the API change near capture binding introduction.
Though captures are usually presented as synthetic type variables, the patch
rather separates them into a new kind of binding which answers true only to
#isCapture() and can provide access to the captured wildcard binding. It allows
clients to take advantage of original wildcard.
Comment 10 Philipe Mulet CLA 2005-04-19 18:17:50 EDT
Requesting PMC approval to release this API change for 3.1 inclusion.
Patch to Signature will follow shortly.
Comment 11 Philipe Mulet CLA 2005-04-19 18:24:13 EDT
Created attachment 20089 [details]
Individual patch for model Signature

(apply to org.eclipse.jdt.core.Signature unit)

This patch previews the API change near capture signature introduction.
Though captures are usually presented as synthetic type variables, the patch
rather separates them into a new kind of signature. 
A capture of a wildcard has a signature prefixed with the '!' character, in a
similar fashion to array signature (where prefix character is '['). Note that
capture signature cannot occur in classfile, but may be revealed by certain
APIs (through DOM AST binding, or selected element...).
Comment 12 Jim des Rivieres CLA 2005-04-20 09:05:06 EDT
Created attachment 20118 [details]
Individual patch for DOM AST ITypeBinding

I've made a number of minor improvements to the specs,
and spec'd captures as having no names.
Comment 13 Jim des Rivieres CLA 2005-04-20 09:21:52 EDT
Created attachment 20121 [details]
Individual patch for DOM AST ITypeBinding 

This is the correct patch file.
Comment 14 Jim des Rivieres CLA 2005-04-20 09:36:36 EDT
Created attachment 20124 [details]
Individual patch for model Signature 

Minor improvements to spec.
Comment 15 Philipe Mulet CLA 2005-04-21 09:07:13 EDT
Changes got released to HEAD.
Comment 16 Olivier Thomann CLA 2005-05-11 10:13:49 EDT
Verified in I20050510-0010