From b60ccdb06e0c8aaee752c6cc351e4bb76cff17cb 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 3b33d456c29..c218df1f78c 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 @@ -1402,6 +1402,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;