langtools/test/tools/javac/generics/UnsoundInference.java
author sogoel
Fri, 15 May 2015 17:43:21 -0700
changeset 30724 0686b5ea7958
parent 5520 86e4b9a9da40
permissions -rw-r--r--
8074514: Group 13d: golden files for tests in tools/javac/generics dir Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
30724
0686b5ea7958 8074514: Group 13d: golden files for tests in tools/javac/generics dir
sogoel
parents: 5520
diff changeset
     2
 * @test /nodynamiccopyright/
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug 5020448
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Generic method allowing passing of types that don't match collection types
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author gafter
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 *
30724
0686b5ea7958 8074514: Group 13d: golden files for tests in tools/javac/generics dir
sogoel
parents: 5520
diff changeset
     7
 * @compile/fail/ref=UnsoundInference.out -XDrawDiagnostics  UnsoundInference.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
import java.util.ArrayList;
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
import java.util.Collection;
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
public class UnsoundInference {
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
    public static void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
        Object[] objArray = {new Object()};
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
        ArrayList<String> strList = new ArrayList<String>();
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
        transferBug(objArray, strList);
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
        String str = strList.get(0);
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
    public static <Var> void transferBug(Var[] from, Collection<Var> to) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
        to.add(from[0]);
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
}