Skip to content

Commit aea822e

Browse files
committed
Fix bug of not prepending instance vars with self
1 parent 794b00e commit aea822e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

java2python/compiler/visitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ def nodeOpExpr(self, node, memo):
641641
""" Accept and processes an operator expression. """
642642
factory = self.factory.expr
643643
self.fs = FS.l + ' ' + node.text + ' ' + FS.r
644-
self.left, self.right = visitors = factory(parent=self), factory()
644+
self.left, self.right = visitors = factory(parent=self), factory(parent=self)
645645
self.zipWalk(node.children, visitors, memo)
646646

647647
acceptAnd = nodeOpExpr

test/Self0.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Self0 {
2+
private int v1 = 100;
3+
public int v2 = 2;
4+
5+
public int test0(){
6+
return v2 + v1;
7+
}
8+
9+
public boolean test1(){
10+
return (v1 == v2 || v2 < v1 );
11+
}
12+
13+
public static void main(String[] args) {
14+
Self0 s = new Self0();
15+
System.out.println(s.test0());
16+
if(s.test1())
17+
System.out.println("True");
18+
else
19+
System.out.println("False");
20+
}
21+
22+
}

0 commit comments

Comments
 (0)