changeset 2853:03939be983dd

8074148: Attr.visitBinary flags error at wrong position Reviewed-by: vromero
author sadayapalam
date Fri, 13 Mar 2015 10:25:46 +0530
parents 2d47da183295
children 42098d16d8f9
files src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java test/tools/javac/expression/BinopVoidTest.java test/tools/javac/expression/BinopVoidTest.out
diffstat 3 files changed, 20 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Mar 13 13:15:24 2015 +0530
+++ b/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/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/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