### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v retrieving revision 1.141 diff -u -r1.141 QualifiedNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 19 Jun 2009 16:29:49 -0000 1.141 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 7 Apr 2010 12:46:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -762,14 +762,19 @@ } public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { - if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { //If inlinable field, forget the access emulation, the code gen will directly target it if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) { return; } if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) { - currentScope.emulateOuterAccess((LocalVariableBinding) this.binding); - } + LocalVariableBinding localVariableBinding = (LocalVariableBinding) this.binding; + if (localVariableBinding != null) { + switch(localVariableBinding.useFlag) { + case LocalVariableBinding.FAKE_USED : + case LocalVariableBinding.USED : + currentScope.emulateOuterAccess(localVariableBinding); + } + } } } @@ -777,7 +782,7 @@ * index is <0 to denote write access emulation */ public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBinding fieldBinding, int index, FlowInfo flowInfo) { - if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; + if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return; // index == 0 denotes the first fieldBinding, index > 0 denotes one of the 'otherBindings', index < 0 denotes a write access (to last binding) if (fieldBinding.constant() != Constant.NotAConstant) return; Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v retrieving revision 1.116 diff -u -r1.116 SingleNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 7 Mar 2009 00:58:59 -0000 1.116 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 7 Apr 2010 12:46:18 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -161,7 +161,7 @@ if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) { currentScope.problemReporter().uninitializedLocalVariable(localBinding, this); } - if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { + if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { localBinding.useFlag = LocalVariableBinding.USED; } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) { localBinding.useFlag = LocalVariableBinding.FAKE_USED; @@ -719,12 +719,18 @@ } public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { - if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { - //If inlinable field, forget the access emulation, the code gen will directly target it - if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) return; - - if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) { - currentScope.emulateOuterAccess((LocalVariableBinding) this.binding); + //If inlinable field, forget the access emulation, the code gen will directly target it + if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) { + return; + } + if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) { + LocalVariableBinding localVariableBinding = (LocalVariableBinding) this.binding; + if (localVariableBinding != null) { + switch(localVariableBinding.useFlag) { + case LocalVariableBinding.FAKE_USED : + case LocalVariableBinding.USED : + currentScope.emulateOuterAccess(localVariableBinding); + } } } } #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java,v retrieving revision 1.59 diff -u -r1.59 InnerEmulationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 18 Mar 2010 16:22:37 -0000 1.59 +++ src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 7 Apr 2010 12:46:23 -0000 @@ -25,7 +25,7 @@ public class InnerEmulationTest extends AbstractRegressionTest { static { // TESTS_NAMES = new String[] { "Bug58069" }; -// TESTS_NUMBERS = new int[] { 23, 24 }; + TESTS_NUMBERS = new int[] { 173, 174 }; // TESTS_RANGE = new int[] { 144, -1 }; } public InnerEmulationTest(String name) { @@ -7065,6 +7065,60 @@ "----------\n" ); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308245 +public void test173() throws Exception { + this.runConformTest( + new String[] { + "X.java",//======================= + "import java.util.ArrayList;\n" + + "import java.util.Comparator;\n" + + "import java.util.List;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " final List yourList = new ArrayList();\n" + + " final List myList = new ArrayList();\n" + + " new Comparator() {\n" + + " public int compare(Object o1, Object o2) {\n" + + " compare(yourList != null ? yourList : myList, yourList);\n" + + " return 0;\n" + + " }\n" + + " };\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308245 +public void test174() throws Exception { + this.runConformTest( + new String[] { + "X.java",//======================= + "import java.util.Comparator;\n" + + "public class X {\n" + + " public static class MyList {\n" + + " int size;\n" + + " }\n" + + " public static void main(String[] args) {\n" + + " final MyList yourList = new MyList();\n" + + " final MyList myList = new MyList();\n" + + " new Comparator() {\n" + + " public int compare(Object o1, Object o2) {\n" + + " return compare((MyList) o1, (MyList) o2);\n" + + " }\n" + + " public int compare(MyList o1, MyList o2) {\n" + + " return foo(yourList != null ? yourList.size : myList.size, yourList.size);\n" + + " }\n" + + " private int foo(int i, int j) {\n" + + " return i - j;\n" + + " }\n" + + " };\n" + + " System.out.println(\"SUCCESS\");\n" + + " }\n" + + "}", + }, + "SUCCESS"); +} public static Class testClass() { return InnerEmulationTest.class; }