8074148: Attr.visitBinary flags error at wrong position

Reviewed-by: vromero
This commit is contained in:
Srikanth Adayapalam 2015-03-13 10:25:46 +05:30
parent c4ebb7f3c0
commit f1f1f0f7e1
3 changed files with 20 additions and 1 deletions

View File

@ -2942,7 +2942,7 @@ public class Attr extends JCTree.Visitor {
public void visitBinary(JCBinary tree) {
// Attribute arguments.
Type left = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.lhs, env));
Type right = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.rhs, env));
Type right = chk.checkNonVoid(tree.rhs.pos(), attribExpr(tree.rhs, env));
// Find operator.
Symbol operator = tree.operator = operators.resolveBinary(tree, tree.getTag(), left, right);
Type owntype = types.createErrorType(tree.type);

View File

@ -0,0 +1,14 @@
/*
* @test /nodynamiccopyright/
* @bug 8074148
* @summary Attr.visitBinary flags error at wrong position
*
* @compile/fail/ref=BinopVoidTest.out -XDrawDiagnostics BinopVoidTest.java
*/
class BinopVoidTest {
void foo() {}
int x = 10 + foo();
int y = foo() + 10;
int z = foo() + foo();
}

View File

@ -0,0 +1,5 @@
BinopVoidTest.java:11:21: compiler.err.void.not.allowed.here
BinopVoidTest.java:12:16: compiler.err.void.not.allowed.here
BinopVoidTest.java:13:16: compiler.err.void.not.allowed.here
BinopVoidTest.java:13:24: compiler.err.void.not.allowed.here
4 errors