View | Details | Raw Unified | Return to bug 132191
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/dom/CompatibilityRulesTests.java (+54 lines)
Lines 730-733 Link Here
730
		}
730
		}
731
	}
731
	}
732
	
732
	
733
	/*
734
	 * Ensures that a method in a subtype doesn't override the corresponding private method in the super type.
735
	 * (regression test for bug 132191 IMethodBinding.overrides(IMethodBinding) returns true even if the given argument is private.)
736
	 */
737
	public void test033() throws JavaModelException {
738
		IMethodBinding[] bindings = createMethodBindings(
739
			new String[] {
740
				"/P/p1/X.java",
741
				"package p1;\n" +
742
				"public class X {\n" +
743
				"  private void foo() {\n" +
744
				"  }\n" +
745
				"}",
746
				"/P/p1/Y.java",
747
				"package p1;\n" +
748
				"public class Y extends X {\n" +
749
				"  void foo() {\n" +
750
				"  }\n" +
751
				"}",
752
			},
753
			new String[] {
754
				"Lp1/Y;.foo()V",
755
				"Lp1/X;.foo()V"
756
			});	
757
		assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1]));
758
	}
759
	
760
	/*
761
	 * Ensures that a method in a subtype doesn't override the corresponding default method in the super type in a different package.
762
	 * (regression test for bug 132191 IMethodBinding.overrides(IMethodBinding) returns true even if the given argument is private.)
763
	 */
764
	public void test034() throws JavaModelException {
765
		IMethodBinding[] bindings = createMethodBindings(
766
			new String[] {
767
				"/P/p1/X.java",
768
				"package p1;\n" +
769
				"public class X {\n" +
770
				"  void foo() {\n" +
771
				"  }\n" +
772
				"}",
773
				"/P/p2/Y.java",
774
				"package p2;\n" +
775
				"public class Y extends p1.X {\n" +
776
				"  void foo() {\n" +
777
				"  }\n" +
778
				"}",
779
			},
780
			new String[] {
781
				"Lp2/Y;.foo()V",
782
				"Lp1/X;.foo()V"
783
			});	
784
		assertTrue("Y#foo() should not override X#foo()", !bindings[0].overrides(bindings[1]));
785
	}
786
	
733
}
787
}
(-)dom/org/eclipse/jdt/core/dom/MethodBinding.java (-1 / +4 lines)
Lines 443-449 Link Here
443
				LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment();
443
				LookupEnvironment lookupEnvironment = this.resolver.lookupEnvironment();
444
				if (lookupEnvironment == null) return false;
444
				if (lookupEnvironment == null) return false;
445
				MethodVerifier methodVerifier = lookupEnvironment.methodVerifier();
445
				MethodVerifier methodVerifier = lookupEnvironment.methodVerifier();
446
				return methodVerifier.doesMethodOverride(this.binding, superMethods[i]);
446
				org.eclipse.jdt.internal.compiler.lookup.MethodBinding superMethod = superMethods[i];
447
				return !superMethod.isPrivate() 
448
					&& !(superMethod.isDefault() && (superMethod.declaringClass.getPackage()) != this.binding.declaringClass.getPackage())
449
					&& methodVerifier.doesMethodOverride(this.binding, superMethod);
447
			}
450
			}
448
		}
451
		}
449
		return false;
452
		return false;

Return to bug 132191