test/langtools/tools/javac/generics/UnsoundInference.java
author vromero
Tue, 24 Apr 2018 08:13:30 -0700
changeset 49872 0798eab12791
parent 47216 71c04702a3d5
permissions -rw-r--r--
8201281: Truncated error message with Incompatible : null Reviewed-by: mcimadamore
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
}