49429
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, Google LLC. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
package com.sun.tools.javac.comp;
|
|
25 |
|
|
26 |
import java.util.function.BiFunction;
|
|
27 |
import java.util.function.Consumer;
|
|
28 |
import java.util.function.Function;
|
|
29 |
import java.util.function.Supplier;
|
|
30 |
|
|
31 |
public class Deduplication {
|
|
32 |
void group(Object... xs) {}
|
|
33 |
|
|
34 |
void test() {
|
|
35 |
group((Function<String, Integer>) x -> x.hashCode());
|
|
36 |
group((Function<Object, Integer>) x -> x.hashCode());
|
|
37 |
|
|
38 |
{
|
|
39 |
int x = 1;
|
|
40 |
group((Supplier<Integer>) () -> x + 1);
|
|
41 |
}
|
|
42 |
{
|
|
43 |
int x = 1;
|
|
44 |
group((Supplier<Integer>) () -> x + 1);
|
|
45 |
}
|
|
46 |
group(
|
|
47 |
(BiFunction<Integer, Integer, ?>) (x, y) -> x + ((y)),
|
|
48 |
(BiFunction<Integer, Integer, ?>) (x, y) -> x + (y),
|
|
49 |
(BiFunction<Integer, Integer, ?>) (x, y) -> x + y,
|
|
50 |
(BiFunction<Integer, Integer, ?>) (x, y) -> (x) + ((y)),
|
|
51 |
(BiFunction<Integer, Integer, ?>) (x, y) -> (x) + (y),
|
|
52 |
(BiFunction<Integer, Integer, ?>) (x, y) -> (x) + y,
|
|
53 |
(BiFunction<Integer, Integer, ?>) (x, y) -> ((x)) + ((y)),
|
|
54 |
(BiFunction<Integer, Integer, ?>) (x, y) -> ((x)) + (y),
|
|
55 |
(BiFunction<Integer, Integer, ?>) (x, y) -> ((x)) + y);
|
|
56 |
|
|
57 |
group(
|
|
58 |
(Function<Integer, Integer>) x -> x + (1 + 2 + 3),
|
|
59 |
(Function<Integer, Integer>) x -> x + 6);
|
|
60 |
|
|
61 |
group((Function<Integer, Integer>) x -> x + 1, (Function<Integer, Integer>) y -> y + 1);
|
|
62 |
|
|
63 |
group((Consumer<Integer>) x -> this.f(), (Consumer<Integer>) x -> this.f());
|
|
64 |
|
|
65 |
group((Consumer<Integer>) y -> this.g());
|
|
66 |
|
|
67 |
group((Consumer<Integer>) x -> f(), (Consumer<Integer>) x -> f());
|
|
68 |
|
|
69 |
group((Consumer<Integer>) y -> g());
|
|
70 |
|
|
71 |
group((Function<Integer, Integer>) x -> this.i, (Function<Integer, Integer>) x -> this.i);
|
|
72 |
|
|
73 |
group((Function<Integer, Integer>) y -> this.j);
|
|
74 |
|
|
75 |
group((Function<Integer, Integer>) x -> i, (Function<Integer, Integer>) x -> i);
|
|
76 |
|
|
77 |
group((Function<Integer, Integer>) y -> j);
|
|
78 |
|
|
79 |
group(
|
|
80 |
(Function<Integer, Integer>) y -> {
|
|
81 |
while (true) {
|
|
82 |
break;
|
|
83 |
}
|
|
84 |
return 42;
|
|
85 |
},
|
|
86 |
(Function<Integer, Integer>) y -> {
|
|
87 |
while (true) {
|
|
88 |
break;
|
|
89 |
}
|
|
90 |
return 42;
|
|
91 |
});
|
|
92 |
|
|
93 |
class Local {
|
|
94 |
int i;
|
|
95 |
|
|
96 |
void f() {}
|
|
97 |
|
|
98 |
{
|
|
99 |
group((Function<Integer, Integer>) x -> this.i);
|
|
100 |
group((Consumer<Integer>) x -> this.f());
|
|
101 |
group((Function<Integer, Integer>) x -> Deduplication.this.i);
|
|
102 |
group((Consumer<Integer>) x -> Deduplication.this.f());
|
|
103 |
}
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
void f() {}
|
|
108 |
|
|
109 |
void g() {}
|
|
110 |
|
|
111 |
int i;
|
|
112 |
int j;
|
|
113 |
}
|