8215368: Make Check.checkOverride call diagnosticPositionFor lazily

Reviewed-by: mcimadamore, vromero
This commit is contained in:
Liam Miller-Cushon 2018-12-13 11:05:40 -08:00
parent 5fad1ca25c
commit bbfc4b7956

@ -26,6 +26,7 @@
package com.sun.tools.javac.comp;
import java.util.*;
import java.util.function.Supplier;
import javax.tools.JavaFileManager;
@ -1797,7 +1798,7 @@ public class Check {
if (!isDeprecatedOverrideIgnorable(other, origin)) {
Lint prevLint = setLint(lint.augment(m));
try {
checkDeprecated(TreeInfo.diagnosticPositionFor(m, tree), m, other);
checkDeprecated(() -> TreeInfo.diagnosticPositionFor(m, tree), m, other);
} finally {
setLint(prevLint);
}
@ -3259,10 +3260,14 @@ public class Check {
}
void checkDeprecated(final DiagnosticPosition pos, final Symbol other, final Symbol s) {
checkDeprecated(() -> pos, other, s);
}
void checkDeprecated(Supplier<DiagnosticPosition> pos, final Symbol other, final Symbol s) {
if ( (s.isDeprecatedForRemoval()
|| s.isDeprecated() && !other.isDeprecated())
&& (s.outermostClass() != other.outermostClass() || s.outermostClass() == null)) {
deferredLintHandler.report(() -> warnDeprecated(pos, s));
deferredLintHandler.report(() -> warnDeprecated(pos.get(), s));
}
}