8074148: Attr.visitBinary flags error at wrong position
authorsadayapalam
Fri, 13 Mar 2015 10:25:46 +0530
changeset 29552 690d0becaf32
parent 29551 cad66be66e2e
child 29553 716d47f5a45e
8074148: Attr.visitBinary flags error at wrong position Reviewed-by: vromero
langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/test/tools/javac/expression/BinopVoidTest.java
langtools/test/tools/javac/expression/BinopVoidTest.out
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Mar 13 13:15:24 2015 +0530
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Mar 13 10:25:46 2015 +0530
@@ -2942,7 +2942,7 @@
     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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/expression/BinopVoidTest.java	Fri Mar 13 10:25:46 2015 +0530
@@ -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();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/expression/BinopVoidTest.out	Fri Mar 13 10:25:46 2015 +0530
@@ -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