Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6650759

Inference of formal type parameter (unused in formal parameters) is not performed

    XMLWordPrintable

Details

    • b72
    • generic, x86
    • generic, linux
    • Verified

    Backports

      Description

        This source code:
        -----------------------------------------------------------------------------
        public class GenericTest {
            
            public static interface Interface<T> { }
            public static class IntegerInterface implements Interface<Integer> { }
            
            public static <I extends Interface<T>, T> T getGenericValue(I test) {
                return null;
            }
            
            public static void testSet(Integer test) { }
            
            public static void main(String args[]) {
                
                Integer test = getGenericValue(new IntegerInterface());
                testSet(getGenericValue(new IntegerInterface())); //flagged as an error
            }
        }
        ---------------------------------------------------------------------------------------

        Produces the following compilation error:
        ---------------------------------------------------------------------------------------
        GenericTest.java:15: testSet(java.lang.Integer) in GenericTest cannot be applied to (java.lang.Object)
                 testSet(getGenericValue(new IntegerInterface())); //flagged as an error
                 ^
        1 error
        ---------------------------------------------------------------------------------------

        On:
        java version "1.7.0-ea"
        Java(TM) SE Runtime Environment (build 1.7.0-ea-b22)
        Java HotSpot(TM) Server VM (build 11.0-b08, mixed mode)

        But not on:
        java version "1.6.0_05-ea"
        Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
        Java HotSpot(TM) Tiered VM (build 1.6.0_05-ea-b04, mixed mode)

        Attachments

          Issue Links

            Activity

              People

                mcimadamore Maurizio Cimadamore
                jlahoda Jan Lahoda
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: