From 64c8cd85d4477aa7d888f3cb2469a6a09d58358b Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Sat, 11 Jan 2020 19:38:00 +0100 Subject: [PATCH] Don't lint during `SuggestedFixes#compilesWithFix` Under certain circumstances this avoids triggering a compiler bug. It is also expected to speed up the trial compilation somewhat. The implicit assumption here is that it is okay to suggest a fix which introduces another warning. (This may not be so in general, but the introduced warning may be less severe or may be resolved manually.) See google/error-prone#849. --- .../com/google/errorprone/fixes/SuggestedFixes.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java b/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java index 9a06342178f..9a0f01b3841 100644 --- a/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java +++ b/check_api/src/main/java/com/google/errorprone/fixes/SuggestedFixes.java @@ -1416,6 +1416,17 @@ private Context createContext() { // but does add them in response to passing --release. Here we invert that operation. continue; } + if (key.equals("-Xlint") + || key.equals("-Xlint:") + || key.equals("-Xdoclint") + || key.equals("-Xdoclint:") + || key.equals("-Xdoclint/package:") + || key.equals("--doclint-format")) { + // For unknown reasons retaining -Xdoclint:reference here can cause an NPE; see #849. Since + // suggested fixes are unlikely to introduce lint errors that cannot be fixed manually, here + // we disable all lint checks. This _may_ also speed up compilation. + continue; + } options.put(key, value); } return context;