View | Details | Raw Unified | Return to bug 308245
Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-5 / +10 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 762-775 Link Here
762
}
762
}
763
763
764
public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
764
public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
765
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)	{
766
	//If inlinable field, forget the access emulation, the code gen will directly target it
765
	//If inlinable field, forget the access emulation, the code gen will directly target it
767
	if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) {
766
	if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) {
768
		return;
767
		return;
769
	}
768
	}
770
	if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) {
769
	if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) {
771
		currentScope.emulateOuterAccess((LocalVariableBinding) this.binding);
770
		LocalVariableBinding localVariableBinding = (LocalVariableBinding) this.binding;
772
	}
771
		if (localVariableBinding != null) {
772
			switch(localVariableBinding.useFlag) {
773
				case LocalVariableBinding.FAKE_USED :
774
				case LocalVariableBinding.USED :
775
					currentScope.emulateOuterAccess(localVariableBinding);
776
			}
777
		}
773
	}
778
	}
774
}
779
}
775
780
Lines 777-783 Link Here
777
 * index is <0 to denote write access emulation
782
 * index is <0 to denote write access emulation
778
 */
783
 */
779
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBinding fieldBinding, int index, FlowInfo flowInfo) {
784
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FieldBinding fieldBinding, int index, FlowInfo flowInfo) {
780
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0)	return;
785
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0) return;
781
	// index == 0 denotes the first fieldBinding, index > 0 denotes one of the 'otherBindings', index < 0 denotes a write access (to last binding)
786
	// index == 0 denotes the first fieldBinding, index > 0 denotes one of the 'otherBindings', index < 0 denotes a write access (to last binding)
782
	if (fieldBinding.constant() != Constant.NotAConstant)
787
	if (fieldBinding.constant() != Constant.NotAConstant)
783
		return;
788
		return;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-8 / +14 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 161-167 Link Here
161
			if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
161
			if (!flowInfo.isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
162
				currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
162
				currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
163
			}
163
			}
164
			if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)	{
164
			if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) {
165
				localBinding.useFlag = LocalVariableBinding.USED;
165
				localBinding.useFlag = LocalVariableBinding.USED;
166
			} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
166
			} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
167
				localBinding.useFlag = LocalVariableBinding.FAKE_USED;
167
				localBinding.useFlag = LocalVariableBinding.FAKE_USED;
Lines 719-730 Link Here
719
}
719
}
720
720
721
public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
721
public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) {
722
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)	{
722
	//If inlinable field, forget the access emulation, the code gen will directly target it
723
		//If inlinable field, forget the access emulation, the code gen will directly target it
723
	if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) {
724
		if (((this.bits & ASTNode.DepthMASK) == 0) || (this.constant != Constant.NotAConstant)) return;
724
		return;
725
725
	}
726
		if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) {
726
	if ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL) {
727
			currentScope.emulateOuterAccess((LocalVariableBinding) this.binding);
727
		LocalVariableBinding localVariableBinding = (LocalVariableBinding) this.binding;
728
		if (localVariableBinding != null) {
729
			switch(localVariableBinding.useFlag) {
730
				case LocalVariableBinding.FAKE_USED :
731
				case LocalVariableBinding.USED :
732
					currentScope.emulateOuterAccess(localVariableBinding);
733
			}
728
		}
734
		}
729
	}
735
	}
730
}
736
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java (-1 / +55 lines)
Lines 25-31 Link Here
25
public class InnerEmulationTest extends AbstractRegressionTest {
25
public class InnerEmulationTest extends AbstractRegressionTest {
26
static {
26
static {
27
//		TESTS_NAMES = new String[] { "Bug58069" };
27
//		TESTS_NAMES = new String[] { "Bug58069" };
28
//		TESTS_NUMBERS = new int[] { 23, 24 };
28
		TESTS_NUMBERS = new int[] { 173, 174 };
29
//		TESTS_RANGE = new int[] { 144, -1 };
29
//		TESTS_RANGE = new int[] { 144, -1 };
30
}
30
}
31
public InnerEmulationTest(String name) {
31
public InnerEmulationTest(String name) {
Lines 7065-7070 Link Here
7065
		"----------\n"
7065
		"----------\n"
7066
	);
7066
	);
7067
}
7067
}
7068
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308245
7069
public void test173() throws Exception {
7070
	this.runConformTest(
7071
		new String[] {
7072
			"X.java",//=======================
7073
			"import java.util.ArrayList;\n" + 
7074
			"import java.util.Comparator;\n" + 
7075
			"import java.util.List;\n" + 
7076
			"public class X {\n" + 
7077
			"	public static void main(String[] args) {\n" + 
7078
			"		final List yourList = new ArrayList();\n" + 
7079
			"		final List myList = new ArrayList();\n" + 
7080
			"		new Comparator() {\n" + 
7081
			"			public int compare(Object o1, Object o2) {\n" + 
7082
			"				compare(yourList != null ? yourList : myList, yourList);\n" + 
7083
			"				return 0;\n" + 
7084
			"			}\n" + 
7085
			"		};\n" + 
7086
			"		System.out.println(\"SUCCESS\");\n" + 
7087
			"	}\n" + 
7088
			"}",
7089
		},
7090
		"SUCCESS");
7091
}
7092
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=308245
7093
public void test174() throws Exception {
7094
	this.runConformTest(
7095
		new String[] {
7096
			"X.java",//=======================
7097
			"import java.util.Comparator;\n" + 
7098
			"public class X {\n" + 
7099
			"	public static class MyList {\n" +
7100
			"		int size;\n" + 
7101
			"	}\n" + 
7102
			"	public static void main(String[] args) {\n" + 
7103
			"		final MyList yourList = new MyList();\n" + 
7104
			"		final MyList myList = new MyList();\n" + 
7105
			"		new Comparator() {\n" + 
7106
			"			public int compare(Object o1, Object o2) {\n" +
7107
			"				return compare((MyList) o1, (MyList) o2);\n" + 
7108
			"			}\n" + 
7109
			"			public int compare(MyList o1, MyList o2) {\n" + 
7110
			"				return foo(yourList != null ? yourList.size : myList.size, yourList.size);\n" + 
7111
			"			}\n" + 
7112
			"			private int foo(int i, int j) {\n" + 
7113
			"				return i - j;\n" + 
7114
			"			}\n" + 
7115
			"		};\n" + 
7116
			"		System.out.println(\"SUCCESS\");\n" + 
7117
			"	}\n" + 
7118
			"}",
7119
		},
7120
		"SUCCESS");
7121
}
7068
public static Class testClass() {
7122
public static Class testClass() {
7069
	return InnerEmulationTest.class;
7123
	return InnerEmulationTest.class;
7070
}
7124
}

Return to bug 308245