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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java (-2 / +18 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 22-27 Link Here
22
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
22
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding;
23
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
23
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
24
import org.eclipse.jdt.internal.compiler.lookup.Scope;
24
import org.eclipse.jdt.internal.compiler.lookup.Scope;
25
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
25
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
26
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
27
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
27
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
28
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
Lines 210-216 Link Here
210
}
211
}
211
212
212
public TypeBinding resolveTypeArgument(ClassScope classScope, ReferenceBinding genericType, int rank) {
213
public TypeBinding resolveTypeArgument(ClassScope classScope, ReferenceBinding genericType, int rank) {
213
    return resolveType(classScope);
214
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057, circularity is allowed when we are
215
	// resolving type arguments i.e interface A<T extends C> {}	interface B extends A<D> {}
216
	// interface D extends C {}	interface C extends B {}
217
	ReferenceBinding ref = classScope.referenceContext.binding;
218
	boolean pauseHierarchyCheck = false;
219
	try {
220
		if (ref.isHierarchyBeingConnected()) {
221
			ref.tagBits |= TagBits.PauseHierarchyCheck;
222
			pauseHierarchyCheck = true;
223
		}
224
	    return resolveType(classScope);
225
	} finally {
226
		if (pauseHierarchyCheck) {
227
			ref.tagBits &= ~TagBits.PauseHierarchyCheck;
228
		}
229
	}
214
}
230
}
215
231
216
public abstract void traverse(ASTVisitor visitor, BlockScope scope);
232
public abstract void traverse(ASTVisitor visitor, BlockScope scope);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-3 / +9 lines)
Lines 1087-1092 Link Here
1087
			compilationUnitScope().recordSuperTypeReference(superType); // to record supertypes
1087
			compilationUnitScope().recordSuperTypeReference(superType); // to record supertypes
1088
			return detectHierarchyCycle(this.referenceContext.binding, (ReferenceBinding) superType, reference);
1088
			return detectHierarchyCycle(this.referenceContext.binding, (ReferenceBinding) superType, reference);
1089
		}
1089
		}
1090
		// Reinstate the code deleted by the fix for https://bugs.eclipse.org/bugs/show_bug.cgi?id=205235
1091
		// For details, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057. 
1092
		if ((superType.tagBits & TagBits.BeginHierarchyCheck) == 0 && superType instanceof SourceTypeBinding)
1093
			// ensure if this is a source superclass that it has already been checked
1094
			((SourceTypeBinding) superType).scope.connectTypeHierarchyWithoutMembers();
1095
1090
		return false;
1096
		return false;
1091
	}
1097
	}
1092
1098
Lines 1105-1111 Link Here
1105
		if (superType.isMemberType()) {
1111
		if (superType.isMemberType()) {
1106
			ReferenceBinding current = superType.enclosingType();
1112
			ReferenceBinding current = superType.enclosingType();
1107
			do {
1113
			do {
1108
				if (current.isHierarchyBeingConnected() && current == sourceType) {
1114
				if (current.isHierarchyBeingActivelyConnected() && current == sourceType) {
1109
					problemReporter().hierarchyCircularity(sourceType, current, reference);
1115
					problemReporter().hierarchyCircularity(sourceType, current, reference);
1110
					sourceType.tagBits |= TagBits.HierarchyHasProblems;
1116
					sourceType.tagBits |= TagBits.HierarchyHasProblems;
1111
					current.tagBits |= TagBits.HierarchyHasProblems;
1117
					current.tagBits |= TagBits.HierarchyHasProblems;
Lines 1158-1168 Link Here
1158
			return hasCycle;
1164
			return hasCycle;
1159
		}
1165
		}
1160
1166
1161
		if (superType.isHierarchyBeingConnected()) {
1167
		if (superType.isHierarchyBeingActivelyConnected()) {
1162
			org.eclipse.jdt.internal.compiler.ast.TypeReference ref = ((SourceTypeBinding) superType).scope.superTypeReference;
1168
			org.eclipse.jdt.internal.compiler.ast.TypeReference ref = ((SourceTypeBinding) superType).scope.superTypeReference;
1163
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133071
1169
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=133071
1164
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121734
1170
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=121734
1165
			if (ref != null && (ref.resolvedType == null || ((ReferenceBinding) ref.resolvedType).isHierarchyBeingConnected())) {
1171
			if (ref != null && (ref.resolvedType == null || ((ReferenceBinding) ref.resolvedType).isHierarchyBeingActivelyConnected())) {
1166
				problemReporter().hierarchyCircularity(sourceType, superType, reference);
1172
				problemReporter().hierarchyCircularity(sourceType, superType, reference);
1167
				sourceType.tagBits |= TagBits.HierarchyHasProblems;
1173
				sourceType.tagBits |= TagBits.HierarchyHasProblems;
1168
				superType.tagBits |= TagBits.HierarchyHasProblems;
1174
				superType.tagBits |= TagBits.HierarchyHasProblems;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java (-1 / +8 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 1074-1079 Link Here
1074
public boolean isHierarchyBeingConnected() {
1074
public boolean isHierarchyBeingConnected() {
1075
	return (this.tagBits & TagBits.EndHierarchyCheck) == 0 && (this.tagBits & TagBits.BeginHierarchyCheck) != 0;
1075
	return (this.tagBits & TagBits.EndHierarchyCheck) == 0 && (this.tagBits & TagBits.BeginHierarchyCheck) != 0;
1076
}
1076
}
1077
/**
1078
 * Returns true if the type hierarchy is being connected "actively" i.e not paused momentatrily, 
1079
 * while resolving type arguments. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057
1080
 */
1081
public boolean isHierarchyBeingActivelyConnected() {
1082
	return (this.tagBits & TagBits.EndHierarchyCheck) == 0 && (this.tagBits & TagBits.BeginHierarchyCheck) != 0 && (this.tagBits & TagBits.PauseHierarchyCheck) == 0;
1083
}
1077
1084
1078
/**
1085
/**
1079
 * Returns true if the type hierarchy is connected
1086
 * Returns true if the type hierarchy is connected
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TagBits.java (-1 / +2 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 39-44 Link Here
39
	// for the type cycle hierarchy check used by ClassScope
39
	// for the type cycle hierarchy check used by ClassScope
40
	long BeginHierarchyCheck = ASTNode.Bit9;  // type
40
	long BeginHierarchyCheck = ASTNode.Bit9;  // type
41
	long EndHierarchyCheck = ASTNode.Bit10; // type
41
	long EndHierarchyCheck = ASTNode.Bit10; // type
42
	long PauseHierarchyCheck = ASTNode.Bit20; // type
42
	long HasParameterAnnotations = ASTNode.Bit11; // method/constructor
43
	long HasParameterAnnotations = ASTNode.Bit11; // method/constructor
43
44
44
45
(-)src/org/eclipse/jdt/core/tests/builder/Java50Tests.java (-1 / +65 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 311-315 Link Here
311
			"Problem : Unhandled exception type Exception [ resource : </Project/p/Use.java> range : <92,132> category : <40> severity : <2>]"
311
			"Problem : Unhandled exception type Exception [ resource : </Project/p/Use.java> range : <92,132> category : <40> severity : <2>]"
312
		);
312
		);
313
	}
313
	}
314
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057
315
	public void testHierarchyNonCycle() throws JavaModelException {
316
		IPath projectPath = env.addProject("Project", "1.5");
317
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
318
		env.setOutputFolder(projectPath, "");
319
320
		env.addClass(projectPath, "superint", "SuperInterface",
321
				"package superint;\n" +
322
				"public interface SuperInterface<G extends SuperInterface.SuperInterfaceGetter,\n" +
323
				"								 S extends SuperInterface.SuperInterfaceSetter> {\n" +
324
				"    public interface SuperInterfaceGetter {}\n" +
325
				"    public interface SuperInterfaceSetter {}\n" +
326
				"}\n"
327
		);
328
		env.addClass(projectPath, "subint", "SubInterface",
329
				"package subint;\n" +
330
				"import superint.SuperInterface;\n" +
331
				"public interface SubInterface extends\n" +
332
				"    SuperInterface<SubInterface.SubInterfaceGetter,\n" +
333
				"                   SubInterface.SubInterfaceSetter> {\n" +
334
				"        public interface SubInterfaceGetter extends SuperInterfaceGetter {}\n" +
335
				"        public interface SubInterfaceSetter extends SuperInterfaceSetter {}\n" +
336
				"}\n"
337
		);
338
339
		fullBuild(projectPath);
340
		expectingProblemsFor(
341
				projectPath,
342
				"Problem : Bound mismatch: The type SubInterface.SubInterfaceGetter is not a valid substitute for the bounded parameter <G extends SuperInterface.SuperInterfaceGetter> of the type SuperInterface<G,S> [ resource : </Project/subint/SubInterface.java> range : <105,136> category : <40> severity : <2>]\n" + 
343
				"Problem : Bound mismatch: The type SubInterface.SubInterfaceSetter is not a valid substitute for the bounded parameter <S extends SuperInterface.SuperInterfaceSetter> of the type SuperInterface<G,S> [ resource : </Project/subint/SubInterface.java> range : <157,188> category : <40> severity : <2>]\n" + 
344
				"Problem : SuperInterfaceGetter cannot be resolved to a type [ resource : </Project/subint/SubInterface.java> range : <244,264> category : <40> severity : <2>]\n" + 
345
				"Problem : SuperInterfaceSetter cannot be resolved to a type [ resource : </Project/subint/SubInterface.java> range : <320,340> category : <40> severity : <2>]"
346
			);
347
	}
348
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=294057 (variation)
349
	public void testHierarchyNonCycle2() throws JavaModelException {
350
		IPath projectPath = env.addProject("Project", "1.5");
351
		env.addExternalJars(projectPath, Util.getJavaClassLibs());
352
		env.setOutputFolder(projectPath, "");
353
354
		env.addClass(projectPath, "superint", "SuperInterface",
355
				"package superint;\n" +
356
				"public interface SuperInterface<G extends SuperInterface.SuperInterfaceGetter,\n" +
357
				"								 S extends SuperInterface.SuperInterfaceSetter> {\n" +
358
				"    public interface SuperInterfaceGetter {}\n" +
359
				"    public interface SuperInterfaceSetter {}\n" +
360
				"}\n"
361
		);
362
		env.addClass(projectPath, "subint", "SubInterface",
363
				"package subint;\n" +
364
				"import superint.SuperInterface;\n" +
365
				"import superint.SuperInterface.SuperInterfaceGetter;\n" +
366
				"import superint.SuperInterface.SuperInterfaceSetter;\n" +
367
				"public interface SubInterface extends\n" +
368
				"    SuperInterface<SubInterface.SubInterfaceGetter,\n" +
369
				"                   SubInterface.SubInterfaceSetter> {\n" +
370
				"        public interface SubInterfaceGetter extends SuperInterfaceGetter {}\n" +
371
				"        public interface SubInterfaceSetter extends SuperInterfaceSetter {}\n" +
372
				"}\n"
373
		);
374
375
		fullBuild(projectPath);
376
		expectingNoProblems();
377
	}
314
378
315
}
379
}

Return to bug 294057