8073616: Duplicate error message: cannot inherit from final (class) F
Ensure that the compiler does not emit duplicate errors at slightly different source positions. Reviewed-by: mcimadamore
This commit is contained in:
parent
90a76d40e5
commit
b79126e437
@ -840,8 +840,10 @@ public class Attr extends JCTree.Visitor {
|
||||
boolean classExpected,
|
||||
boolean interfaceExpected,
|
||||
boolean checkExtensible) {
|
||||
final DiagnosticPosition pos = tree.hasTag(TYPEAPPLY) ?
|
||||
(((JCTypeApply) tree).clazz).pos() : tree.pos();
|
||||
if (t.tsym.isAnonymous()) {
|
||||
log.error(tree.pos(), "cant.inherit.from.anon");
|
||||
log.error(pos, "cant.inherit.from.anon");
|
||||
return types.createErrorType(t);
|
||||
}
|
||||
if (t.isErroneous())
|
||||
@ -849,29 +851,29 @@ public class Attr extends JCTree.Visitor {
|
||||
if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) {
|
||||
// check that type variable is already visible
|
||||
if (t.getUpperBound() == null) {
|
||||
log.error(tree.pos(), "illegal.forward.ref");
|
||||
log.error(pos, "illegal.forward.ref");
|
||||
return types.createErrorType(t);
|
||||
}
|
||||
} else {
|
||||
t = chk.checkClassType(tree.pos(), t, checkExtensible);
|
||||
t = chk.checkClassType(pos, t, checkExtensible);
|
||||
}
|
||||
if (interfaceExpected && (t.tsym.flags() & INTERFACE) == 0) {
|
||||
log.error(tree.pos(), "intf.expected.here");
|
||||
log.error(pos, "intf.expected.here");
|
||||
// return errType is necessary since otherwise there might
|
||||
// be undetected cycles which cause attribution to loop
|
||||
return types.createErrorType(t);
|
||||
} else if (checkExtensible &&
|
||||
classExpected &&
|
||||
(t.tsym.flags() & INTERFACE) != 0) {
|
||||
log.error(tree.pos(), "no.intf.expected.here");
|
||||
log.error(pos, "no.intf.expected.here");
|
||||
return types.createErrorType(t);
|
||||
}
|
||||
if (checkExtensible &&
|
||||
((t.tsym.flags() & FINAL) != 0)) {
|
||||
log.error(tree.pos(),
|
||||
log.error(pos,
|
||||
"cant.inherit.from.final", t.tsym);
|
||||
}
|
||||
chk.checkNonCyclic(tree.pos(), t);
|
||||
chk.checkNonCyclic(pos, t);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8073616
|
||||
* @summary Ensure compiler does not emit duplicate error messages at slightly different source positions
|
||||
*
|
||||
* @compile/fail/ref=CheckNoDuplicateErrors.out -XDrawDiagnostics CheckNoDuplicateErrors.java
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
final class CheckNoDuplicateErrors_01<T> {}
|
||||
|
||||
public class CheckNoDuplicateErrors extends CheckNoDuplicateErrors_01<String>
|
||||
implements ArrayList<String> {
|
||||
CheckNoDuplicateErrors_01 f = new CheckNoDuplicateErrors_01<String> () { };
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
CheckNoDuplicateErrors.java:13:45: compiler.err.cant.inherit.from.final: CheckNoDuplicateErrors_01
|
||||
CheckNoDuplicateErrors.java:14:48: compiler.err.intf.expected.here
|
||||
CheckNoDuplicateErrors.java:15:39: compiler.err.cant.inherit.from.final: CheckNoDuplicateErrors_01
|
||||
3 errors
|
@ -1,3 +1,2 @@
|
||||
TargetType68.java:61:32: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
|
||||
TargetType68.java:61:39: compiler.err.cant.inherit.from.final: TargetType68.XYChart.Series
|
||||
2 errors
|
||||
1 error
|
||||
|
Loading…
x
Reference in New Issue
Block a user