### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v retrieving revision 1.112 diff -u -r1.112 MethodVerifier15.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 23 Jun 2010 08:25:53 -0000 1.112 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 7 Jul 2010 10:46:20 -0000 @@ -541,6 +541,21 @@ int count = index + 1; while (--count > 0) { MethodBinding match = matchingInherited[count]; + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556 + MethodBinding interfaceMethod = null, implementation = null; + if (first.declaringClass.isInterface()) { + interfaceMethod = first; + } else if (first.declaringClass.isClass()) { + implementation = first; + } + if (match.declaringClass.isInterface()) { + interfaceMethod = match; + } else if (match.declaringClass.isClass()) { + implementation = match; + } + if (interfaceMethod != null && implementation != null && !isAsVisible(implementation, interfaceMethod)) + problemReporter().visibilityConflict(typeParameter, implementation, interfaceMethod); + if (areReturnTypesCompatible(first, match)) continue; // unrelated interfaces - check to see if return types are compatible if (first.declaringClass.isInterface() && match.declaringClass.isInterface() && areReturnTypesCompatible(match, first)) Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v retrieving revision 1.412 diff -u -r1.412 ProblemReporter.java --- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jul 2010 05:56:10 -0000 1.412 +++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jul 2010 10:46:27 -0000 @@ -7430,10 +7430,21 @@ // 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method. IProblem.MethodReducesVisibility, new String[] {new String(inheritedMethod.declaringClass.readableName())}, - new String[] {new String(inheritedMethod.declaringClass.shortReadableName())}, + new String[] {new String(""), new String(inheritedMethod.declaringClass.shortReadableName())}, //$NON-NLS-1$ currentMethod.sourceStart(), currentMethod.sourceEnd()); } +public void visibilityConflict(TypeParameter typeParameter, MethodBinding currentMethod, MethodBinding inheritedMethod) { + this.handle( + // Cannot reduce the visibility of the inherited method from %1 + // 8.4.6.3 - The access modifier of an hiding method must provide at least as much access as the hidden method. + // 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method. + IProblem.MethodReducesVisibility, + new String[] {new String(inheritedMethod.declaringClass.readableName())}, + new String[] {new String(inheritedMethod.shortReadableName()), new String(inheritedMethod.declaringClass.shortReadableName())}, + typeParameter.sourceStart(), + typeParameter.sourceEnd()); +} public void wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location) { this.handle( IProblem.WildcardFieldAssignment, Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v retrieving revision 1.257 diff -u -r1.257 messages.properties --- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 4 Mar 2010 16:43:55 -0000 1.257 +++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 7 Jul 2010 10:46:28 -0000 @@ -348,7 +348,7 @@ 406 = This instance method cannot override the static method from {0} 407 = This static method cannot hide the instance method from {0} 408 = The static method {0} conflicts with the abstract method in {1} -409 = Cannot reduce the visibility of the inherited method from {0} +409 = Cannot reduce the visibility of the inherited method {0} from {1} 410 = The method {0} does not override the inherited method from {1} since it is private to a different package 411 = This class must implement the inherited abstract method {1}, but cannot override it since it is not visible from {0}. Either make the type abstract or make the inherited method visible 412 = The method {0} overrides a deprecated method from {1} #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.821 diff -u -r1.821 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 24 Jun 2010 07:30:00 -0000 1.821 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 7 Jul 2010 10:47:39 -0000 @@ -50513,4 +50513,22 @@ "Type mismatch: cannot convert from AnotherClass to AnotherClass\n" + "----------\n"); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556 +public void test1463() { + this.runNegativeTest( + new String[] { + "BaseType.java", + "public interface BaseType {\n" + + " BaseType clone() throws CloneNotSupportedException;\n" + + "}\n" + + "interface SubType extends BaseType {\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in BaseType.java (at line 4)\n" + + " interface SubType extends BaseType {\n" + + " ^\n" + + "Cannot reduce the visibility of the inherited method clone() from BaseType\n" + + "----------\n"); +} } \ No newline at end of file