@@ -28,9 +28,9 @@ cast: '(' TYPE ')' expression
28
28
+
29
29
[source,Painless]
30
30
----
31
- <1> int i = (int)5L;
32
- <2> Map m = new HashMap();
33
- <3> HashMap hm = (HashMap)m;
31
+ int i = (int)5L; <1>
32
+ Map m = new HashMap(); <2>
33
+ HashMap hm = (HashMap)m; <3>
34
34
----
35
35
+
36
36
<1> declare `int i`;
@@ -75,10 +75,10 @@ following table:
75
75
+
76
76
[source,Painless]
77
77
----
78
- <1> int a = 1;
79
- <2> long b = a;
80
- <3> short c = (short)b;
81
- <4> double e = (double)a;
78
+ int a = 1; <1>
79
+ long b = a; <2>
80
+ short c = (short)b; <3>
81
+ double e = (double)a; <4>
82
82
----
83
83
+
84
84
<1> declare `int a`;
@@ -101,9 +101,9 @@ following table:
101
101
+
102
102
[source,Painless]
103
103
----
104
- <1> int a = 1.0; // error
105
- <2> int b = 2;
106
- <3> byte c = b; // error
104
+ int a = 1.0; // error <1>
105
+ int b = 2; <2>
106
+ byte c = b; // error <3>
107
107
----
108
108
+
109
109
<1> declare `int i`;
@@ -132,11 +132,11 @@ or the target type is a descendant of the original type.
132
132
+
133
133
[source,Painless]
134
134
----
135
- <1> List x;
136
- <2> ArrayList y = new ArrayList();
137
- <3> x = y;
138
- <4> y = (ArrayList)x;
139
- <5> x = (List)y;
135
+ List x; <1>
136
+ ArrayList y = new ArrayList(); <2>
137
+ x = y; <3>
138
+ y = (ArrayList)x; <4>
139
+ x = (List)y; <5>
140
140
----
141
141
+
142
142
<1> declare `List x`;
@@ -161,9 +161,9 @@ or the target type is a descendant of the original type.
161
161
+
162
162
[source,Painless]
163
163
----
164
- <1> List x = new ArrayList();
165
- <2> ArrayList y = x; // error
166
- <3> Map m = (Map)x; // error
164
+ List x = new ArrayList(); <1>
165
+ ArrayList y = x; // error <2>
166
+ Map m = (Map)x; // error <3>
167
167
----
168
168
+
169
169
<1> declare `List x`;
@@ -201,11 +201,11 @@ based on the current type value the `def` type value represents.
201
201
+
202
202
[source,Painless]
203
203
----
204
- <1> def d0 = 3;
205
- <2> d0 = new ArrayList();
206
- <3> Object o = new HashMap();
207
- <4> def d1 = o;
208
- <5> int i = d1.size();
204
+ def d0 = 3; <1>
205
+ d0 = new ArrayList(); <2>
206
+ Object o = new HashMap(); <3>
207
+ def d1 = o; <4>
208
+ int i = d1.size(); <5>
209
209
----
210
210
+
211
211
<1> declare `def d0`;
@@ -236,12 +236,12 @@ based on the current type value the `def` type value represents.
236
236
+
237
237
[source,Painless]
238
238
----
239
- <1> def d = 1.0;
240
- <2> int i = (int)d;
241
- <3> d = 1;
242
- <4> float f = d;
243
- <5> d = new ArrayList();
244
- <6> List l = d;
239
+ def d = 1.0; <1>
240
+ int i = (int)d; <2>
241
+ d = 1; <3>
242
+ float f = d; <4>
243
+ d = new ArrayList(); <5>
244
+ List l = d; <6>
245
245
----
246
246
+
247
247
<1> declare `def d`;
@@ -274,10 +274,10 @@ based on the current type value the `def` type value represents.
274
274
+
275
275
[source,Painless]
276
276
----
277
- <1> def d = 1;
278
- <2> short s = d; // error
279
- <3> d = new HashMap();
280
- <4> List l = d; // error
277
+ def d = 1; <1>
278
+ short s = d; // error <2>
279
+ d = new HashMap(); <3>
280
+ List l = d; // error <4>
281
281
----
282
282
<1> declare `def d`;
283
283
implicit cast `int 1` to `def` -> `def`;
@@ -314,8 +314,8 @@ Use the cast operator to convert a <<string-type, `String` type>> value into a
314
314
+
315
315
[source,Painless]
316
316
----
317
- <1> char c = (char)"C";
318
- <2> c = (char)'c';
317
+ char c = (char)"C"; <1>
318
+ c = (char)'c'; <2>
319
319
----
320
320
+
321
321
<1> declare `char c`;
@@ -328,8 +328,8 @@ Use the cast operator to convert a <<string-type, `String` type>> value into a
328
328
+
329
329
[source,Painless]
330
330
----
331
- <1> String s = "s";
332
- <2> char c = (char)s;
331
+ String s = "s"; <1>
332
+ char c = (char)s; <2>
333
333
----
334
334
<1> declare `String s`;
335
335
store `String "s"` to `s`;
@@ -368,10 +368,10 @@ value and vice versa.
368
368
+
369
369
[source,Painless]
370
370
----
371
- <1> List l = new ArrayList();
372
- <2> l.add(1);
373
- <3> Integer I = Integer.valueOf(0);
374
- <4> int i = l.get(i);
371
+ List l = new ArrayList(); <1>
372
+ l.add(1); <2>
373
+ Integer I = Integer.valueOf(0); <3>
374
+ int i = l.get(i); <4>
375
375
----
376
376
+
377
377
<1> declare `List l`;
@@ -399,10 +399,10 @@ value and vice versa.
399
399
+
400
400
[source,Painless]
401
401
----
402
- <1> Integer x = 1; // error
403
- <2> Integer y = (Integer)1; // error
404
- <3> int a = Integer.valueOf(1); // error
405
- <4> int b = (int)Integer.valueOf(1); // error
402
+ Integer x = 1; // error <1>
403
+ Integer y = (Integer)1; // error <2>
404
+ int a = Integer.valueOf(1); // error <3>
405
+ int b = (int)Integer.valueOf(1); // error <4>
406
406
----
407
407
+
408
408
<1> declare `Integer x`;
@@ -437,9 +437,9 @@ based on the type the `def` value represents.
437
437
+
438
438
[source,Painless]
439
439
----
440
- <1> double d = 2 + 2.0;
441
- <2> def x = 1;
442
- <3> float f = x + 2.0F;
440
+ double d = 2 + 2.0; <1>
441
+ def x = 1; <2>
442
+ float f = x + 2.0F; <3>
443
443
----
444
444
<1> declare `double d`;
445
445
promote `int 2` and `double 2.0 @0`: result `double`;
0 commit comments