File tree Expand file tree Collapse file tree
java/ql/test/library-tests/typeflow Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,4 +102,20 @@ public void m9(Object[] xs, int i) {
102102 default -> { }
103103 }
104104 }
105+
106+ public void m10 (Object o ) {
107+ String s = "Hello world!" ;
108+ Object o2 = s ; // Alas, the type information, it is lost
109+
110+ if (o2 instanceof CharSequence cs ) {
111+ // Partially recovered statically, but we should know cs is an alias of o and therefore it's really a string.
112+ Object target = cs ;
113+ }
114+
115+ // The same applies to a pattern case
116+ switch (o2 ) {
117+ case CharSequence cs -> { Object target = cs ; }
118+ default -> { }
119+ }
120+ }
105121}
Original file line number Diff line number Diff line change 1414| A.java:70:23:70:24 | x2 | Integer | false |
1515| A.java:92:18:92:18 | n | Integer | false |
1616| A.java:100:20:100:20 | n | Integer | false |
17+ | A.java:110:9:110:10 | o2 | String | false |
18+ | A.java:112:23:112:24 | cs | String | false |
19+ | A.java:116:13:116:14 | o2 | String | false |
20+ | A.java:117:49:117:50 | cs | String | false |
1721| UnionTypes.java:45:7:45:7 | x | Inter | false |
1822| UnionTypes.java:48:23:48:23 | x | Inter | false |
You can’t perform that action at this time.
0 commit comments