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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-1 lines)
Lines 202-208 Link Here
202
	for (int i = 0, length = topLevelTypes.length; i < length; i++) {
202
	for (int i = 0, length = topLevelTypes.length; i < length; i++) {
203
		ClassScope scope = topLevelTypes[i].scope;
203
		ClassScope scope = topLevelTypes[i].scope;
204
		scope.checkParameterizedTypeBounds();
204
		scope.checkParameterizedTypeBounds();
205
		scope.checkParameterizedSuperTypeCollisions();
206
	}
205
	}
207
}
206
}
208
/*
207
/*
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-18 / +24 lines)
Lines 621-660 Link Here
621
		fieldBinding.modifiers = modifiers;
621
		fieldBinding.modifiers = modifiers;
622
	}
622
	}
623
623
624
	public void checkParameterizedSuperTypeCollisions() {
624
	/**
625
	 * Check for super type collisions (both superinterfaces and type variables).
626
	 * @return the list of non-colliding superinterfaces
627
	 */	
628
	public ReferenceBinding[] computeNonCollidingSuperInterfaces() {
625
		// check for parameterized interface collisions (when different parameterizations occur)
629
		// check for parameterized interface collisions (when different parameterizations occur)
626
		SourceTypeBinding sourceType = referenceContext.binding;
630
		SourceTypeBinding sourceType = referenceContext.binding;
627
		ReferenceBinding[] interfaces = sourceType.superInterfaces;
631
		ReferenceBinding[] nonCollidingSuperInterfaces = sourceType.superInterfaces; // lazy allocation of clone if problem is discovered
628
		int count = interfaces.length;
632
		int count = nonCollidingSuperInterfaces.length;
629
		Map invocations = new HashMap(2);
633
		Map invocations = new HashMap(2);
630
		ReferenceBinding itsSuperclass = sourceType.isInterface() ? null : sourceType.superclass;
634
		ReferenceBinding itsSuperclass = sourceType.isInterface() ? null : sourceType.superclass;
631
		nextInterface: for (int i = 0, length = count; i < length; i++) {
635
		nextInterface: for (int i = 0, length = count; i < length; i++) {
632
			ReferenceBinding one =  interfaces[i];
636
			ReferenceBinding one =  nonCollidingSuperInterfaces[i];
633
			if (one == null) continue nextInterface;
637
			if (one == null) continue nextInterface;
634
			if (itsSuperclass != null && hasErasedCandidatesCollisions(itsSuperclass, one, invocations, sourceType, referenceContext)) {
638
			if (itsSuperclass != null && hasErasedCandidatesCollisions(itsSuperclass, one, invocations, sourceType, referenceContext)) {
635
				interfaces[i] = null;
639
				if (nonCollidingSuperInterfaces == sourceType.superInterfaces) { // lazy cloning
640
					System.arraycopy(sourceType.superInterfaces, 0, nonCollidingSuperInterfaces = new ReferenceBinding[count], 0, count);
641
				}
642
				nonCollidingSuperInterfaces[i] = null;
636
				count--;
643
				count--;
637
				continue nextInterface;
644
				continue nextInterface;
638
			}
645
			}
639
			nextOtherInterface: for (int j = 0; j < i; j++) {
646
			nextOtherInterface: for (int j = 0; j < i; j++) {
640
				ReferenceBinding two = interfaces[j];
647
				ReferenceBinding two = nonCollidingSuperInterfaces[j];
641
				if (two == null) continue nextOtherInterface;
648
				if (two == null) continue nextOtherInterface;
642
				if (hasErasedCandidatesCollisions(one, two, invocations, sourceType, referenceContext)) {
649
				if (hasErasedCandidatesCollisions(one, two, invocations, sourceType, referenceContext)) {
643
					interfaces[i] = null;
650
					if (nonCollidingSuperInterfaces == sourceType.superInterfaces) { // lazy cloning
651
						System.arraycopy(sourceType.superInterfaces, 0, nonCollidingSuperInterfaces = new ReferenceBinding[count], 0, count);
652
					}
653
					nonCollidingSuperInterfaces[i] = null;
644
					count--;
654
					count--;
645
					continue nextInterface;
655
					continue nextInterface;
646
				}
656
				}
647
			}
657
			}
648
		}
658
		}
649
		if (count < interfaces.length) {
659
		if (count < nonCollidingSuperInterfaces.length) {
650
			if (count == 0) {
660
			if (count == 0) {
651
				sourceType.superInterfaces = Binding.NO_SUPERINTERFACES;
661
				nonCollidingSuperInterfaces = Binding.NO_SUPERINTERFACES;
652
			} else {
662
			} else {
653
				ReferenceBinding[] newInterfaceBindings = new ReferenceBinding[count];
663
				ReferenceBinding[] newInterfaceBindings = new ReferenceBinding[count];
654
				for (int i = 0, j = 0, l = interfaces.length; i < l; i++)
664
				for (int i = 0, j = 0, l = nonCollidingSuperInterfaces.length; i < l; i++)
655
					if (interfaces[i] != null)
665
					if (nonCollidingSuperInterfaces[i] != null)
656
						newInterfaceBindings[j++] = interfaces[i];
666
						newInterfaceBindings[j++] = nonCollidingSuperInterfaces[i];
657
				sourceType.superInterfaces = newInterfaceBindings;
667
				nonCollidingSuperInterfaces = newInterfaceBindings;
658
			}
668
			}
659
		}
669
		}
660
670
Lines 683-693 Link Here
683
				}
693
				}
684
			}
694
			}
685
		}
695
		}
686
696
		return nonCollidingSuperInterfaces;
687
		ReferenceBinding[] memberTypes = referenceContext.binding.memberTypes;
688
		if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES)
689
			for (int i = 0, size = memberTypes.length; i < size; i++)
690
				 ((SourceTypeBinding) memberTypes[i]).scope.checkParameterizedSuperTypeCollisions();
691
	}
697
	}
692
698
693
	private void checkForInheritedMemberTypes(SourceTypeBinding sourceType) {
699
	private void checkForInheritedMemberTypes(SourceTypeBinding sourceType) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (-1 / +2 lines)
Lines 389-395 Link Here
389
	ReferenceBinding superclass = this.type.isInterface()
389
	ReferenceBinding superclass = this.type.isInterface()
390
		? this.type.scope.getJavaLangObject() // check interface methods against Object
390
		? this.type.scope.getJavaLangObject() // check interface methods against Object
391
		: this.type.superclass(); // class or enum
391
		: this.type.superclass(); // class or enum
392
	computeInheritedMethods(superclass, type.superInterfaces());
392
	ReferenceBinding[] interfaces = this.type.scope.computeNonCollidingSuperInterfaces();
393
	computeInheritedMethods(superclass, interfaces);
393
}
394
}
394
/*
395
/*
395
Binding creation is responsible for reporting:
396
Binding creation is responsible for reporting:

Return to bug 142653