View | Details | Raw Unified | Return to bug 235658 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-3 / +19 lines)
Lines 876-885 Link Here
876
		ReferenceBinding memberType = enclosingType.getMemberType(typeName);
876
		ReferenceBinding memberType = enclosingType.getMemberType(typeName);
877
		if (memberType != null) {
877
		if (memberType != null) {
878
			unitScope.recordTypeReference(memberType);
878
			unitScope.recordTypeReference(memberType);
879
			if (enclosingReceiverType == null
879
			if (enclosingReceiverType == null) {
880
				? memberType.canBeSeenBy(getCurrentPackage())
880
				if (memberType.canBeSeenBy(getCurrentPackage())) {
881
				: memberType.canBeSeenBy(enclosingType, enclosingReceiverType))
882
					return memberType;
881
					return memberType;
882
				}
883
				// maybe some type in the compilation unit is extending some class in some package
884
				// and the selection is for some protected inner class of that superclass
885
				// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235658
886
				if (this instanceof CompilationUnitScope) {
887
					TypeDeclaration[] types = ((CompilationUnitScope)this).referenceContext.types;
888
					if (types != null) {
889
						for (int i = 0, max = types.length; i < max; i++) {
890
							if (memberType.canBeSeenBy(enclosingType, types[i].binding)) {
891
								return memberType;
892
							}
893
						}
894
					}
895
				}
896
			} else if (memberType.canBeSeenBy(enclosingType, enclosingReceiverType)) {
897
				return memberType;
898
			}
883
			return new ProblemReferenceBinding(new char[][]{typeName}, memberType, ProblemReasons.NotVisible);
899
			return new ProblemReferenceBinding(new char[][]{typeName}, memberType, ProblemReasons.NotVisible);
884
		}
900
		}
885
		return null;
901
		return null;
(-)src/org/eclipse/jdt/core/tests/model/ResolveTests.java (-4 / +45 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 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 12-21 Link Here
12
12
13
import java.io.IOException;
13
import java.io.IOException;
14
14
15
import org.eclipse.core.runtime.CoreException;
15
import junit.framework.Test;
16
import org.eclipse.jdt.core.*;
17
16
18
import junit.framework.*;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.jdt.core.IClassFile;
19
import org.eclipse.jdt.core.ICompilationUnit;
20
import org.eclipse.jdt.core.IJavaElement;
21
import org.eclipse.jdt.core.IJavaProject;
22
import org.eclipse.jdt.core.ILocalVariable;
23
import org.eclipse.jdt.core.IMethod;
24
import org.eclipse.jdt.core.ISourceRange;
25
import org.eclipse.jdt.core.IType;
26
import org.eclipse.jdt.core.JavaCore;
27
import org.eclipse.jdt.core.JavaModelException;
28
import org.eclipse.jdt.core.WorkingCopyOwner;
19
29
20
public class ResolveTests extends AbstractJavaModelTests {
30
public class ResolveTests extends AbstractJavaModelTests {
21
	ICompilationUnit wc = null;
31
	ICompilationUnit wc = null;
Lines 2546-2550 Link Here
2546
		elements
2556
		elements
2547
	);
2557
	);
2548
}
2558
}
2559
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235658
2560
// To verify that "open declaration" works for a protected interface, which is
2561
// an inner type of an extending class's superclass.
2562
public void testInterfaceX() throws JavaModelException {
2563
	this.workingCopies = new ICompilationUnit[2];
2564
	this.workingCopies[0] = getWorkingCopy(
2565
		"/Resolve/src/test/Bug.java",
2566
		"package test;\n"+
2567
		"public class Bug {\n" +
2568
		"  void foo() {}\n" +
2569
		"  protected interface Proto {}\n" +
2570
		"}\n");
2571
2572
	this.workingCopies[1] = getWorkingCopy(
2573
		"/Resolve/src/Type.java",
2574
		"import test.Bug;\n"+
2575
		"import test.Bug.*;\n"+
2576
		"class Type extends Bug implements Proto {\n" +
2577
		"}\n");
2578
2579
	String str = this.workingCopies[1].getSource();
2580
	int start = str.lastIndexOf("Proto");
2581
	int length = "Proto".length();
2582
	IJavaElement[] elements =  this.workingCopies[1].codeSelect(start, length, this.wcOwner);
2583
2584
	assertElementsEqual(
2585
			"Unexpected elements",
2586
			"Proto [in Bug [in [Working copy] Bug.java [in test [in src [in Resolve]]]]]",
2587
			elements
2588
	);
2589
}
2549
2590
2550
}
2591
}

Return to bug 235658