Project: JDT
Bug 146532 [inline] inline method produces compile error with this-qualified remote field access
Reported: 2006-06-12 06:17:10 | Status: resolved fixed

Version: 3.2.0 Build id: I20060602-1317 When applying refactor / inline on the call to nonRecursiveAnalyseCodeLeaf in Z, the resulting code does not compile. Source files: X.java public class X { X left, right; Type resolvedType; public void checkNPE(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { } public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // keep implementation in sync with CombinedBinaryExpression#analyseCode if (this.resolvedType.id == Type.T_JavaLangString) { return this.right.analyseCode( currentScope, flowContext, this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits()) .unconditionalInits(); } else { this.left.checkNPE(currentScope, flowContext, flowInfo); flowInfo = this.left.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits(); this.right.checkNPE(currentScope, flowContext, flowInfo); return this.right.analyseCode(currentScope, flowContext, flowInfo).unconditionalInits(); } } FlowInfo nonRecursiveAnalyseCodeLeaf(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { if (this.resolvedType.id != Type.T_JavaLangString) { this.left.checkNPE(currentScope, flowContext, flowInfo); } return this.left.analyseCode(currentScope, flowContext, flowInfo). unconditionalInits(); } } class FlowInfo { FlowInfo unconditionalInits() { return null; } } class BlockScope { } class FlowContext { } class Type { public int id; public static final int T_JavaLangString = 0; } Z.java public class Z extends X { X internalNodes[]; int depth; public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { flowInfo = this.internalNodes[0].nonRecursiveAnalyseCodeLeaf( // inline this call currentScope, flowContext, flowInfo); return flowInfo; } } Result of the refactoring: public class Z extends X { X internalNodes[]; int depth; public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { X r = this.internalNodes[0]; if (r.resolvedType.r.id != Type.T_JavaLangString) { r.left.checkNPE(currentScope, flowContext, flowInfo); } flowInfo = r.left.analyseCode(currentScope, flowContext, flowInfo). unconditionalInits(); return flowInfo; } } note the extraneous r in r.resolvedType.r.id.

Files changed in fix:
org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/receiver_in/TestRemoteFieldReceiver.java org.eclipse.jdt.ui.tests.refactoring/resources/InlineMethodWorkspace/TestCases/receiver_out/TestRemoteFieldReceiver.java org.eclipse.jdt.ui.tests.refactoring/test cases/org/eclipse/jdt/ui/tests/refactoring/InlineMethodTests.java org.eclipse.jdt.ui/core refactoring/org/eclipse/jdt/internal/corext/refactoring/code/SourceAnalyzer.java