Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.4, 1.8-beta-1
-
None
Description
Inside of of ReturnAdder, there is the code:
BlockStatement newBlock = new BlockStatement();
newBlock.setVariableScope(node.getVariableScope());
This is meant to ensure that the variable scope of the new block statement has the appropriate variable scope. However, node is of type MethodNode. The code block should be as follows:
BlockStatement newBlock = new BlockStatement(); Statement code = node.getCode(); if (code instanceof BlockStatement) { newBlock.setVariableScope(((BlockStatement) code).getVariableScope()); }
If code is not of type BlockStatement, then we don't need to set the variable scope.