8215368: Make Check.checkOverride call diagnosticPositionFor lazily
authorcushon
Thu, 13 Dec 2018 11:05:40 -0800
changeset 53037 e84983c2735e
parent 53036 d5a2a29ca589
child 53038 9dd0a2fdec24
8215368: Make Check.checkOverride call diagnosticPositionFor lazily Reviewed-by: mcimadamore, vromero
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Dec 13 10:08:22 2018 -0800
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Thu Dec 13 11:05:40 2018 -0800
@@ -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 @@
         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 @@
     }
 
     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));
         }
     }