Bug 347600 - [1.7][compiler] Suspect bounds check failure after inference.
Summary: [1.7][compiler] Suspect bounds check failure after inference.
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7.1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-30 01:35 EDT by Srikanth Sankaran CLA
Modified: 2011-08-05 02:54 EDT (History)
2 users (show)

See Also:
Olivier_Thomann: review+


Attachments
Patch & test under consideration (7.54 KB, patch)
2011-06-01 03:28 EDT, Srikanth Sankaran CLA
no flags Details | Diff
Patch & test under consideration (12.68 KB, patch)
2011-06-01 13:45 EDT, Srikanth Sankaran CLA
no flags Details | Diff
Patch & test under consideration (12.92 KB, patch)
2011-06-01 21:24 EDT, Srikanth Sankaran CLA
no flags Details | Diff
Patch & test under consideration (13.67 KB, patch)
2011-06-02 01:30 EDT, 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 Srikanth Sankaran CLA 2011-05-30 01:35:58 EDT
The following program compiles fine with JDK 7b142, but fails to
compile with eclipse HEAD and BETA_JAVA7


class A {}
class B<V> extends A {} 
class D extends B<E> {}
class E extends B<D> {}

public class X<T, Y extends B<U>, U extends B<Y>> {    
    public static <T1, Y1 extends B<U1>, U1 extends B<Y1>> X<T1, Y1, U1> getX() {
    	return null;
    }
    X<B, ? extends D, ? extends E> f = getX();   
}

We report:

 Bound mismatch: The generic method getX() of type X<T,Y,U> is not applicable for the arguments (). The inferred type D&B<E&B<Y1>> is not a valid substitute for the bounded parameter <Y1 extends B<U1>>

I wonder if this is not another lingering type variable issue.
Comment 1 Srikanth Sankaran CLA 2011-05-30 01:36:33 EDT
I'll investigate this one.
Comment 2 Srikanth Sankaran CLA 2011-05-30 01:54:47 EDT
Released org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest._test347600() as a disabled junit test.
Comment 3 Srikanth Sankaran CLA 2011-06-01 03:28:49 EDT
Created attachment 197063 [details]
Patch & test under consideration
Comment 4 Srikanth Sankaran CLA 2011-06-01 09:47:44 EDT
Comment on attachment 197063 [details]
Patch & test under consideration

Close, but no cigar.
Comment 5 Srikanth Sankaran CLA 2011-06-01 13:45:22 EDT
Created attachment 197121 [details]
Patch & test under consideration
Comment 6 Srikanth Sankaran CLA 2011-06-01 21:24:59 EDT
Created attachment 197203 [details]
Patch & test under consideration

Earlier patch did not terminate recursion properly leading to
some failures in GenericTypeTests.java.

New patch is under test.
Comment 7 Srikanth Sankaran CLA 2011-06-02 01:30:01 EDT
Created attachment 197216 [details]
Patch & test under consideration

Same patch - cleaned up quite a bit and better commented.
Comment 8 Srikanth Sankaran CLA 2011-06-02 03:14:21 EDT
Passes all tests. Released in BETA_JAVA7 branch.
Comment 9 Srikanth Sankaran CLA 2011-06-02 03:37:04 EDT
Olivier, please review, TIA.

Rather than reviewing the patch, it would be better to just compare:

(1) ParameterizedGenericMethodBinding.java versions 1.70.2.5 with 1.70
(2) Scope.java versions 1.380.2.9 with 1.380.2.8

This contains the cumulative fixes for 

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=242159
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=341795
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=347600
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=347145
    https://bugs.eclipse.org/bugs/show_bug.cgi?id=347746

This will be lot simpler than reviewing the patches attached to
each of them.
Comment 10 Olivier Thomann CLA 2011-06-29 10:23:17 EDT
Looks good.
I'll take more time to be more familiar with the specification part you are referring in your comments.
Comment 11 Satyam Kandula CLA 2011-07-01 08:52:36 EDT
Verified using Eclipse Java 7 Support(Beta) feature patch v20110623-0900.