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

(-)src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java (+28 lines)
Lines 9478-9481 Link Here
9478
		"----------\n"
9478
		"----------\n"
9479
	);
9479
	);
9480
}
9480
}
9481
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=271303
9482
public void test186() {
9483
	this.runNegativeTest(
9484
		new String[] {
9485
			"p1/A.java",
9486
			"package p1;\n" +
9487
			"public class A { void m() {} }\n",
9488
			"p2/B.java",
9489
			"package p2;\n" +
9490
			"public class B extends p1.A { void m() {} }\n",
9491
			"p1/C.java",
9492
			"package p1;\n" +
9493
			"public class C extends p2.B { @Override void m() {} }"
9494
		},
9495
		"----------\n" + 
9496
		"1. WARNING in p2\\B.java (at line 2)\n" + 
9497
		"	public class B extends p1.A { void m() {} }\n" + 
9498
		"	                                   ^^^\n" + 
9499
		"The method B.m() does not override the inherited method from A since it is private to a different package\n" + 
9500
		"----------\n" + 
9501
		"----------\n" + 
9502
		"1. WARNING in p1\\C.java (at line 2)\n" + 
9503
		"	public class C extends p2.B { @Override void m() {} }\n" + 
9504
		"	                                             ^^^\n" + 
9505
		"The method C.m() does not override the inherited method from B since it is private to a different package\n" + 
9506
		"----------\n"
9507
	);
9508
}
9481
}
9509
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier.java (-5 / +5 lines)
Lines 576-586 Link Here
576
					}
576
					}
577
				}
577
				}
578
			}
578
			}
579
			MethodBinding[] nonVisible = (MethodBinding[]) nonVisibleDefaultMethods.get(inheritedMethod.selector);
580
			if (nonVisible != null)
581
				for (int i = 0, l = nonVisible.length; i < l; i++)
582
					if (areMethodsCompatible(nonVisible[i], inheritedMethod))
583
						continue nextMethod;
584
579
585
			if (!inheritedMethod.isDefault() || inheritedMethod.declaringClass.fPackage == this.type.fPackage) {
580
			if (!inheritedMethod.isDefault() || inheritedMethod.declaringClass.fPackage == this.type.fPackage) {
586
				if (existingMethods == null) {
581
				if (existingMethods == null) {
Lines 592-597 Link Here
592
				}
587
				}
593
				this.inheritedMethods.put(inheritedMethod.selector, existingMethods);
588
				this.inheritedMethods.put(inheritedMethod.selector, existingMethods);
594
			} else {
589
			} else {
590
				MethodBinding[] nonVisible = (MethodBinding[]) nonVisibleDefaultMethods.get(inheritedMethod.selector);
591
				if (nonVisible != null)
592
					for (int i = 0, l = nonVisible.length; i < l; i++)
593
						if (areMethodsCompatible(nonVisible[i], inheritedMethod))
594
							continue nextMethod;
595
				if (nonVisible == null) {
595
				if (nonVisible == null) {
596
					nonVisible = new MethodBinding[] {inheritedMethod};
596
					nonVisible = new MethodBinding[] {inheritedMethod};
597
				} else {
597
				} else {

Return to bug 271303