Skip to content

Commit 8a75871

Browse files
committed
test and fix vars defined inside blocks
1 parent 39a0323 commit 8a75871

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

java2python/compiler/visitor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class Interface(Class):
358358
""" Interface -> accepts AST branches for Java interfaces. """
359359

360360

361-
class MethodContent(Base):
361+
class MethodContent(VarAcceptor, Base):
362362
""" MethodContent -> accepts trees for blocks within methods. """
363363

364364
def acceptAssert(self, node, memo):
@@ -613,7 +613,7 @@ def acceptWhile(self, node, memo):
613613
whileStat.walk(blkNode, memo)
614614

615615

616-
class Method(VarAcceptor, ModifiersAcceptor, MethodContent):
616+
class Method(ModifiersAcceptor, MethodContent):
617617
""" Method -> accepts AST branches for method-level objects. """
618618

619619
def acceptFormalParamStdDecl(self, node, memo):

test/If8.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class If8 {
2+
public static void main(String[] args) {
3+
if (true) {
4+
int y = 1;
5+
System.out.println(0 + y);
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)