author | vromero |
Wed, 11 Apr 2018 14:52:32 -0400 | |
changeset 49577 | faf02d65df7d |
parent 49541 | 4f6887eade94 |
child 49887 | 39446351e625 |
permissions | -rw-r--r-- |
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() { |
|
49577
faf02d65df7d
8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
vromero
parents:
49541
diff
changeset
|
35 |
|
faf02d65df7d
8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
vromero
parents:
49541
diff
changeset
|
36 |
group( |
faf02d65df7d
8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
vromero
parents:
49541
diff
changeset
|
37 |
(Runnable) () -> { ( (Runnable) () -> {} ).run(); }, |
faf02d65df7d
8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
vromero
parents:
49541
diff
changeset
|
38 |
(Runnable) () -> { ( (Runnable) () -> {} ).run(); } |
faf02d65df7d
8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
vromero
parents:
49541
diff
changeset
|
39 |
); |
faf02d65df7d
8201440: javac should create unique DynamicMethodSymbols at LambdaToMethod
vromero
parents:
49541
diff
changeset
|
40 |
|
49429 | 41 |
group((Function<String, Integer>) x -> x.hashCode()); |
42 |
group((Function<Object, Integer>) x -> x.hashCode()); |
|
43 |
||
44 |
{ |
|
45 |
int x = 1; |
|
46 |
group((Supplier<Integer>) () -> x + 1); |
|
47 |
} |
|
48 |
{ |
|
49 |
int x = 1; |
|
50 |
group((Supplier<Integer>) () -> x + 1); |
|
51 |
} |
|
52 |
group( |
|
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 |
(BiFunction<Integer, Integer, ?>) (x, y) -> (x) + ((y)), |
|
57 |
(BiFunction<Integer, Integer, ?>) (x, y) -> (x) + (y), |
|
58 |
(BiFunction<Integer, Integer, ?>) (x, y) -> (x) + y, |
|
59 |
(BiFunction<Integer, Integer, ?>) (x, y) -> ((x)) + ((y)), |
|
60 |
(BiFunction<Integer, Integer, ?>) (x, y) -> ((x)) + (y), |
|
61 |
(BiFunction<Integer, Integer, ?>) (x, y) -> ((x)) + y); |
|
62 |
||
63 |
group( |
|
64 |
(Function<Integer, Integer>) x -> x + (1 + 2 + 3), |
|
65 |
(Function<Integer, Integer>) x -> x + 6); |
|
66 |
||
67 |
group((Function<Integer, Integer>) x -> x + 1, (Function<Integer, Integer>) y -> y + 1); |
|
68 |
||
69 |
group((Consumer<Integer>) x -> this.f(), (Consumer<Integer>) x -> this.f()); |
|
70 |
||
71 |
group((Consumer<Integer>) y -> this.g()); |
|
72 |
||
73 |
group((Consumer<Integer>) x -> f(), (Consumer<Integer>) x -> f()); |
|
74 |
||
75 |
group((Consumer<Integer>) y -> g()); |
|
76 |
||
77 |
group((Function<Integer, Integer>) x -> this.i, (Function<Integer, Integer>) x -> this.i); |
|
78 |
||
79 |
group((Function<Integer, Integer>) y -> this.j); |
|
80 |
||
81 |
group((Function<Integer, Integer>) x -> i, (Function<Integer, Integer>) x -> i); |
|
82 |
||
83 |
group((Function<Integer, Integer>) y -> j); |
|
84 |
||
85 |
group( |
|
49541
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
86 |
(Function<Integer, Integer>) |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
87 |
y -> { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
88 |
while (true) { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
89 |
break; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
90 |
} |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
91 |
return 42; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
92 |
}, |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
93 |
(Function<Integer, Integer>) |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
94 |
y -> { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
95 |
while (true) { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
96 |
break; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
97 |
} |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
98 |
return 42; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
99 |
}); |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
100 |
|
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
101 |
group( |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
102 |
(Function<Integer, Integer>) |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
103 |
x -> { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
104 |
int y = x; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
105 |
return y; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
106 |
}, |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
107 |
(Function<Integer, Integer>) |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
108 |
x -> { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
109 |
int y = x; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
110 |
return y; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
111 |
}); |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
112 |
|
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
113 |
group( |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
114 |
(Function<Integer, Integer>) |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
115 |
x -> { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
116 |
int y = 0, z = x; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
117 |
return y; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
118 |
}); |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
119 |
group( |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
120 |
(Function<Integer, Integer>) |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
121 |
x -> { |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
122 |
int y = 0, z = x; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
123 |
return z; |
4f6887eade94
8201194: Handle local variable declarations in lambda deduplication
cushon
parents:
49429
diff
changeset
|
124 |
}); |
49429 | 125 |
|
126 |
class Local { |
|
127 |
int i; |
|
128 |
||
129 |
void f() {} |
|
130 |
||
131 |
{ |
|
132 |
group((Function<Integer, Integer>) x -> this.i); |
|
133 |
group((Consumer<Integer>) x -> this.f()); |
|
134 |
group((Function<Integer, Integer>) x -> Deduplication.this.i); |
|
135 |
group((Consumer<Integer>) x -> Deduplication.this.f()); |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
||
140 |
void f() {} |
|
141 |
||
142 |
void g() {} |
|
143 |
||
144 |
int i; |
|
145 |
int j; |
|
146 |
} |