8317336: Assertion error thrown during 'this' escape analysis
Reviewed-by: vromero
This commit is contained in:
parent
16fd43c5eb
commit
a8473b7079
@ -678,7 +678,11 @@ class ThisEscapeAnalyzer extends TreeScanner {
|
||||
|
||||
@Override
|
||||
public void visitForeachLoop(JCEnhancedForLoop tree) {
|
||||
visitLooped(tree, super::visitForeachLoop);
|
||||
visitLooped(tree, foreach -> {
|
||||
scan(foreach.expr);
|
||||
refs.discardExprs(depth); // we don't handle iterator() yet
|
||||
scan(foreach.body);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -729,7 +733,10 @@ class ThisEscapeAnalyzer extends TreeScanner {
|
||||
|
||||
@Override
|
||||
public void visitLambda(JCLambda lambda) {
|
||||
visitDeferred(() -> visitScoped(false, () -> super.visitLambda(lambda)));
|
||||
visitDeferred(() -> visitScoped(false, () -> {
|
||||
scan(lambda.body);
|
||||
refs.discardExprs(depth); // needed in case body is a JCExpression
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -601,4 +601,20 @@ public class ThisEscape {
|
||||
public static final class Sub2 extends ThisEscapeSealed {
|
||||
}
|
||||
}
|
||||
|
||||
// Verify no assertion error occurs (JDK-8317336)
|
||||
public static class ThisEscapeAssertionError {
|
||||
public ThisEscapeAssertionError() {
|
||||
System.out.println((Supplier<Object>)() -> this);
|
||||
}
|
||||
}
|
||||
|
||||
// Verify no assertion error occurs (JDK-8317336)
|
||||
public static class ThisEscapeAssertionError2 {
|
||||
public ThisEscapeAssertionError2() {
|
||||
ThisEscapeAssertionError2[] array = new ThisEscapeAssertionError2[] { this };
|
||||
for (Object obj : array)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user