Skip to content

Commit cb5e611

Browse files
AntonKozlovYuri Nesterenko
authored andcommitted
8222251: preflow visitor is not visiting lambda expressions
Backport-of: 40155b1
1 parent 3c1e0cf commit cb5e611

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2723,7 +2723,7 @@ public void visitClassDef(JCClassDecl that) {
27232723
public void visitLambda(JCLambda that) {
27242724
// or lambda expressions!
27252725
}
2726-
}.scan(tree);
2726+
}.scan(tree.body);
27272727
}
27282728

27292729
Types.MapVisitor<DiagnosticPosition> targetChecker = new Types.MapVisitor<DiagnosticPosition>() {
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. 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+
/*
25+
* @test
26+
* @bug 8222251
27+
* @summary preflow visitor is not visiting lambda expressions
28+
* @compile PreflowNotVisitingLambdaExpTest.java
29+
*/
30+
31+
public class PreflowNotVisitingLambdaExpTest {
32+
interface HandleCallback<T, X extends Exception> {
33+
T withHandle(Handle handle) throws X;
34+
}
35+
36+
interface HandleConsumer<X extends Exception> {
37+
void useHandle(Handle handle) throws X;
38+
}
39+
40+
interface Handle {}
41+
42+
interface Jdbi {
43+
<R, X extends Exception> R withHandle(HandleCallback<R, X> callback) throws X;
44+
<X extends Exception> void useHandle(final HandleConsumer<X> callback) throws X;
45+
}
46+
47+
interface ObjectAssert<ACTUAL> {
48+
void isSameAs(ACTUAL t);
49+
}
50+
51+
static <T> ObjectAssert<T> assertThat(T actual) {
52+
return null;
53+
}
54+
55+
private Jdbi jdbi;
56+
57+
public void nestedUseHandle() {
58+
jdbi.withHandle(h1 -> {
59+
jdbi.useHandle(h2 ->
60+
assertThat(h1).isSameAs(h2));
61+
return null;
62+
});
63+
}
64+
}

0 commit comments

Comments
 (0)