1 /*
 2  * @test /nodynamiccopyright/
 3  * @bug 8244513
 4  * @summary Test conditional expression typing involving inlines.
 5  * @compile/fail/ref=ConditionalTypeTest.out -XDrawDiagnostics ConditionalTypeTest.java
 6  */
 7 
 8 final class ConditionalTypeTest {
 9     interface I {}
10     static primitive class Node implements I {}
11     static void foo(int i) {
12         var ret1 = (i == 0) ? new XNodeWrapper() : new Node();
13         ret1 = "String cannot be assigned to I";
14         var ret2 = (i == 0) ? 10 : new XNodeWrapper();
15         ret2 = "String can be assigned to I";
16         var ret3 = (i == 0) ? new XNodeWrapper() : 10;
17         ret3 = "String can be assigned to Object";
18         var ret4 = (i == 0) ? new XNodeWrapper() : new ConditionalTypeTest();
19         ret4 = "String can be assigned to Object";
20         var ret5 = (i == 0) ? Integer.valueOf(10) : new ConditionalTypeTest();
21         ret5 = "String can be assigned to Object";
22 
23         var ret6 = (i == 0) ? new Node() : new Node();
24         ret6 = "String cannot be assigned to Node";
25 
26         var ret7 = (i == 0) ? (Node.ref) new Node() : (Node.ref) null;
27         ret7 = "String cannot be assigned to Node.ref";
28 
29         var ret8 = (i == 0) ? new Node() : (Node.ref) null;
30         ret8 = "String cannot be assigned to Node";
31 
32         var ret9 = (i == 0) ? (Node.ref) new Node() : new Node();
33         ret9 = "String cannot be assigned to Node";
34     }
35     static primitive class XNodeWrapper implements I {}
36 }