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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java (+15 lines)
Lines 541-546 Link Here
541
				int count = index + 1;
541
				int count = index + 1;
542
				while (--count > 0) {
542
				while (--count > 0) {
543
					MethodBinding match = matchingInherited[count];
543
					MethodBinding match = matchingInherited[count];
544
					// https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556
545
					MethodBinding interfaceMethod = null, implementation = null;
546
					if (first.declaringClass.isInterface()) {
547
						interfaceMethod = first;
548
					} else if (first.declaringClass.isClass()) {
549
						implementation = first;
550
					}
551
					if (match.declaringClass.isInterface()) {
552
						interfaceMethod = match;
553
					} else if (match.declaringClass.isClass()) {
554
						implementation = match;
555
					}
556
					if (interfaceMethod != null && implementation != null && !isAsVisible(implementation, interfaceMethod))
557
						problemReporter().inheritedMethodReducesVisibility(typeParameter, implementation, new MethodBinding [] {interfaceMethod});
558
					
544
					if (areReturnTypesCompatible(first, match)) continue;
559
					if (areReturnTypesCompatible(first, match)) continue;
545
					// unrelated interfaces - check to see if return types are compatible
560
					// unrelated interfaces - check to see if return types are compatible
546
					if (first.declaringClass.isInterface() && match.declaringClass.isInterface() && areReturnTypesCompatible(match, first))
561
					if (first.declaringClass.isInterface() && match.declaringClass.isInterface() && areReturnTypesCompatible(match, first))
(-)compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java (-3 / +9 lines)
Lines 2747-2753 Link Here
2747
		location.sourceStart,
2747
		location.sourceStart,
2748
		location.sourceEnd);
2748
		location.sourceEnd);
2749
}
2749
}
2750
public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2750
private void inheritedMethodReducesVisibility(int sourceStart, int sourceEnd, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2751
	StringBuffer concreteSignature = new StringBuffer();
2751
	StringBuffer concreteSignature = new StringBuffer();
2752
	concreteSignature
2752
	concreteSignature
2753
		.append(concreteMethod.declaringClass.readableName())
2753
		.append(concreteMethod.declaringClass.readableName())
Lines 2767-2774 Link Here
2767
		new String[] {
2767
		new String[] {
2768
			shortSignature.toString(),
2768
			shortSignature.toString(),
2769
			new String(abstractMethods[0].declaringClass.shortReadableName())},
2769
			new String(abstractMethods[0].declaringClass.shortReadableName())},
2770
		type.sourceStart(),
2770
		sourceStart,
2771
		type.sourceEnd());
2771
		sourceEnd);
2772
}
2773
public void inheritedMethodReducesVisibility(SourceTypeBinding type, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2774
	inheritedMethodReducesVisibility(type.sourceStart(), type.sourceEnd(), concreteMethod, abstractMethods);
2775
}
2776
public void inheritedMethodReducesVisibility(TypeParameter typeParameter, MethodBinding concreteMethod, MethodBinding[] abstractMethods) {
2777
	inheritedMethodReducesVisibility(typeParameter.sourceStart(), typeParameter.sourceEnd(), concreteMethod, abstractMethods);
2772
}
2778
}
2773
public void inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length) {
2779
public void inheritedMethodsHaveIncompatibleReturnTypes(ASTNode location, MethodBinding[] inheritedMethods, int length) {
2774
	StringBuffer methodSignatures = new StringBuffer();
2780
	StringBuffer methodSignatures = new StringBuffer();
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+18 lines)
Lines 50513-50516 Link Here
50513
		"Type mismatch: cannot convert from AnotherClass<capture#1-of ? extends IReferencedInterface> to AnotherClass<IReferencedInterface>\n" + 
50513
		"Type mismatch: cannot convert from AnotherClass<capture#1-of ? extends IReferencedInterface> to AnotherClass<IReferencedInterface>\n" + 
50514
		"----------\n");
50514
		"----------\n");
50515
}
50515
}
50516
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556
50517
public void test1463() {
50518
	this.runNegativeTest(
50519
		new String[] {
50520
			"BaseType.java",
50521
            "public interface BaseType {\n" +
50522
            "	   BaseType clone() throws CloneNotSupportedException;\n" +
50523
            "}\n" +
50524
            "interface SubType<T extends BaseType & java.io.Closeable> extends BaseType {\n" +
50525
            "}\n"
50526
		},
50527
		"----------\n" + 
50528
		"1. ERROR in BaseType.java (at line 4)\n" + 
50529
		"	interface SubType<T extends BaseType & java.io.Closeable> extends BaseType {\n" + 
50530
		"	                  ^\n" + 
50531
		"The inherited method Object.clone() cannot hide the public abstract method in BaseType\n" + 
50532
		"----------\n");
50533
}
50516
}
50534
}

Return to bug 314556