blob: b9d2752edf13ff63d9da8dc8762c284f092198ef [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4package lambdadesugaring;
5
6public class ValueAdjustments {
7 interface B2i {
8 int foo(Byte i);
9 }
10
11 interface BnUnB {
12 Object foo(boolean z, Boolean Z, byte b, Byte B, char c, Character C, short s, Short S,
13 int i, Integer I, long l, Long L, float f, Float F, double d, Double D);
14 }
15
16 interface iz {
17 boolean f();
18 }
19
20 interface iZ {
21 Boolean f();
22 }
23
24 interface ib {
25 byte f();
26 }
27
28 interface iO {
29 Object f();
30 }
31
32 interface iN {
33 Number f();
34 }
35
36 interface iB {
37 Byte f();
38 }
39
40 interface ic {
41 char f();
42 }
43
44 interface iC {
45 Character f();
46 }
47
48 interface is {
49 short f();
50 }
51
52 interface iS {
53 Short f();
54 }
55
56 interface ii {
57 int f();
58 }
59
60 interface iI {
61 Integer f();
62 }
63
64 interface ij {
65 long f();
66 }
67
68 interface iJ {
69 Long f();
70 }
71
72 interface if_ {
73 float f();
74 }
75
76 interface iF {
77 Float f();
78 }
79
80 interface id {
81 double f();
82 }
83
84 interface iD {
85 Double f();
86 }
87
88 private static void checkObject(StringBuffer builder) {
89 builder
90 .append(((iO) ValueAdjustments::z).f()).append(' ')
91 .append(((iO) ValueAdjustments::Z).f()).append(' ')
92 .append(((iO) ValueAdjustments::b).f()).append(' ')
93 .append(((iO) ValueAdjustments::B).f()).append(' ')
94 .append(((iO) ValueAdjustments::c).f()).append(' ')
95 .append(((iO) ValueAdjustments::C).f()).append(' ')
96 .append(((iO) ValueAdjustments::s).f()).append(' ')
97 .append(((iO) ValueAdjustments::S).f()).append(' ')
98 .append(((iO) ValueAdjustments::i).f()).append(' ')
99 .append(((iO) ValueAdjustments::I).f()).append(' ')
100 .append(((iO) ValueAdjustments::j).f()).append(' ')
101 .append(((iO) ValueAdjustments::J).f()).append(' ')
102 .append(((iO) ValueAdjustments::f).f()).append(' ')
103 .append(((iO) ValueAdjustments::F).f()).append(' ')
104 .append(((iO) ValueAdjustments::d).f()).append(' ')
105 .append(((iO) ValueAdjustments::D).f()).append('\n');
106 }
107
108 private static void checkNumber(StringBuffer builder) {
109 builder
110 .append(((iN) ValueAdjustments::b).f()).append(' ')
111 .append(((iN) ValueAdjustments::B).f()).append(' ')
112 .append(((iN) ValueAdjustments::s).f()).append(' ')
113 .append(((iN) ValueAdjustments::S).f()).append(' ')
114 .append(((iN) ValueAdjustments::i).f()).append(' ')
115 .append(((iN) ValueAdjustments::I).f()).append(' ')
116 .append(((iN) ValueAdjustments::j).f()).append(' ')
117 .append(((iN) ValueAdjustments::J).f()).append(' ')
118 .append(((iN) ValueAdjustments::f).f()).append(' ')
119 .append(((iN) ValueAdjustments::F).f()).append(' ')
120 .append(((iN) ValueAdjustments::d).f()).append(' ')
121 .append(((iN) ValueAdjustments::D).f()).append('\n');
122 }
123
124 private static void checkBoxes(StringBuffer builder) {
125 builder
126 .append(((iZ) ValueAdjustments::z).f()).append(' ')
127 .append(((iB) ValueAdjustments::b).f()).append(' ')
128 .append(((iC) ValueAdjustments::c).f()).append(' ')
129 .append(((iS) ValueAdjustments::s).f()).append(' ')
130 .append(((iI) ValueAdjustments::i).f()).append(' ')
131 .append(((iJ) ValueAdjustments::j).f()).append(' ')
132 .append(((iF) ValueAdjustments::f).f()).append(' ')
133 .append(((iD) ValueAdjustments::d).f()).append('\n');
134 }
135
136 private static void checkDouble(StringBuffer builder) {
137 builder
138 .append(((id) ValueAdjustments::b).f()).append(' ')
139 .append(((id) ValueAdjustments::B).f()).append(' ')
140 .append(((id) ValueAdjustments::s).f()).append(' ')
141 .append(((id) ValueAdjustments::S).f()).append(' ')
142 .append(((id) ValueAdjustments::c).f()).append(' ')
143 .append(((id) ValueAdjustments::C).f()).append(' ')
144 .append(((id) ValueAdjustments::i).f()).append(' ')
145 .append(((id) ValueAdjustments::I).f()).append(' ')
146 .append(((id) ValueAdjustments::j).f()).append(' ')
147 .append(((id) ValueAdjustments::J).f()).append(' ')
148 .append(((id) ValueAdjustments::f).f()).append(' ')
149 .append(((id) ValueAdjustments::F).f()).append(' ')
150 .append(((id) ValueAdjustments::d).f()).append(' ')
151 .append(((id) ValueAdjustments::D).f()).append('\n');
152 }
153
154 private static void checkFloat(StringBuffer builder) {
155 builder
156 .append(((if_) ValueAdjustments::b).f()).append(' ')
157 .append(((if_) ValueAdjustments::B).f()).append(' ')
158 .append(((if_) ValueAdjustments::s).f()).append(' ')
159 .append(((if_) ValueAdjustments::S).f()).append(' ')
160 .append(((if_) ValueAdjustments::c).f()).append(' ')
161 .append(((if_) ValueAdjustments::C).f()).append(' ')
162 .append(((if_) ValueAdjustments::i).f()).append(' ')
163 .append(((if_) ValueAdjustments::I).f()).append(' ')
164 .append(((if_) ValueAdjustments::j).f()).append(' ')
165 .append(((if_) ValueAdjustments::J).f()).append(' ')
166 .append(((if_) ValueAdjustments::f).f()).append(' ')
167 .append(((if_) ValueAdjustments::F).f()).append('\n');
168 }
169
170 private static void checkLong(StringBuffer builder) {
171 builder
172 .append(((ij) ValueAdjustments::b).f()).append(' ')
173 .append(((ij) ValueAdjustments::B).f()).append(' ')
174 .append(((ij) ValueAdjustments::s).f()).append(' ')
175 .append(((ij) ValueAdjustments::S).f()).append(' ')
176 .append(((ij) ValueAdjustments::c).f()).append(' ')
177 .append(((ij) ValueAdjustments::C).f()).append(' ')
178 .append(((ij) ValueAdjustments::i).f()).append(' ')
179 .append(((ij) ValueAdjustments::I).f()).append(' ')
180 .append(((ij) ValueAdjustments::j).f()).append(' ')
181 .append(((ij) ValueAdjustments::J).f()).append('\n');
182 }
183
184 private static void checkInt(StringBuffer builder) {
185 builder
186 .append(((ii) ValueAdjustments::b).f()).append(' ')
187 .append(((ii) ValueAdjustments::B).f()).append(' ')
188 .append(((ii) ValueAdjustments::s).f()).append(' ')
189 .append(((ii) ValueAdjustments::S).f()).append(' ')
190 .append(((ii) ValueAdjustments::c).f()).append(' ')
191 .append(((ii) ValueAdjustments::C).f()).append(' ')
192 .append(((ii) ValueAdjustments::i).f()).append(' ')
193 .append(((ii) ValueAdjustments::I).f()).append('\n');
194 }
195
196 private static void checkShort(StringBuffer builder) {
197 builder
198 .append(((is) ValueAdjustments::b).f()).append(' ')
199 .append(((is) ValueAdjustments::B).f()).append(' ')
200 .append(((is) ValueAdjustments::s).f()).append(' ')
201 .append(((is) ValueAdjustments::S).f()).append('\n');
202 }
203
204 private static void checkChar(StringBuffer builder) {
205 builder
206 .append(((ic) ValueAdjustments::c).f()).append(' ')
207 .append(((ic) ValueAdjustments::C).f()).append('\n');
208 }
209
210 private static void checkByte(StringBuffer builder) {
211 builder
212 .append(((ib) ValueAdjustments::b).f()).append(' ')
213 .append(((ib) ValueAdjustments::B).f()).append('\n');
214 }
215
216 private static void checkBoolean(StringBuffer builder) {
217 builder
218 .append(((iz) ValueAdjustments::z).f()).append(' ')
219 .append(((iz) ValueAdjustments::Z).f()).append('\n');
220 }
221
222 private static void checkMisc(StringBuffer builder) {
223 builder
224 .append(((BnUnB) ValueAdjustments::boxingAndUnboxing).foo(true, false, (byte) 1, (byte) 2,
225 (char) 33, (char) 44, (short) 5, (short) 6, 7, 8, 9, 10L, 11, 12f, 13, 14d))
226 .append('\n')
227 .append(((BnUnB) ValueAdjustments::boxingAndUnboxingW).foo(true, false, (byte) 1, (byte) 2,
228 (char) 33, (char) 44, (short) 5, (short) 6, 7, 8, 9, 10L, 11, 12f, 13, 14d))
229 .append('\n')
230 .append(((B2i) (Integer::new)).foo(Byte.valueOf((byte) 44))).append('\n');
231 }
232
233 static String boxingAndUnboxing(Boolean Z, boolean z, Byte B, byte b, Character C, char c,
234 Short S, short s, Integer I, int i, Long L, long l, Float F, float f, Double D, double d) {
235 return "" + Z + ":" + z + ":" + B + ":" + b + ":" + C + ":" + c + ":" + S + ":" + s
236 + ":" + I + ":" + i + ":" + L + ":" + l + ":" + F + ":" + f + ":" + D + ":" + d;
237 }
238
239 static String boxingAndUnboxingW(boolean Z, boolean z, double B, double b,
240 double C, double c, double S, double s, double I, double i, double L, double l,
241 double F, double f, double D, double d) {
242 return "" + Z + ":" + z + ":" + B + ":" + b + ":" + C + ":" + c + ":" + S + ":" + s
243 + ":" + I + ":" + i + ":" + L + ":" + l + ":" + F + ":" + f + ":" + D + ":" + d;
244 }
245
246 static boolean z() {
247 return true;
248 }
249
250 static byte b() {
251 return 8;
252 }
253
254 static char c() {
255 return 'c';
256 }
257
258 static short s() {
259 return 16;
260 }
261
262 static int i() {
263 return 32;
264 }
265
266 static long j() {
267 return 64;
268 }
269
270 static float f() {
271 return 0.32f;
272 }
273
274 static double d() {
275 return 0.64;
276 }
277
278 static Boolean Z() {
279 return false;
280 }
281
282 static Byte B() {
283 return -8;
284 }
285
286 static Character C() {
287 return 'C';
288 }
289
290 static Short S() {
291 return -16;
292 }
293
294 static Integer I() {
295 return -32;
296 }
297
298 static Long J() {
299 return -64L;
300 }
301
302 static Float F() {
303 return -0.32f;
304 }
305
306 static Double D() {
307 return -0.64;
308 }
309
310 public static void main(String[] args) {
311 StringBuffer builder = new StringBuffer();
312
313 checkBoolean(builder);
314 checkByte(builder);
315 checkChar(builder);
316 checkShort(builder);
317 checkInt(builder);
318 checkLong(builder);
319 checkFloat(builder);
320 checkDouble(builder);
321
322 checkBoxes(builder);
323 checkNumber(builder);
324 checkObject(builder);
325
326 checkMisc(builder);
327
328 System.out.println(builder.toString());
329 }
330}