Run CheckMissingAndExtraRequires as a compile pass rather than just as a callback.
Otherwise, the initial reset() call gets skipped, so we fail to report missing goog.* requires in files that don't already have at least one goog.* require.
@@ -44,7 +44,11 @@ class LintPassConfig extends PassConfig.PassConfigDelegate {
@Override protected List<PassFactory> getChecks() {
return ImmutableList.of(
- earlyLintChecks, variableReferenceCheck, closureRewriteClass, lateLintChecks);
+ earlyLintChecks,
+ checkRequires,
+ variableReferenceCheck,
+ closureRewriteClass,
+ lateLintChecks);
}
@Override protected List<PassFactory> getOptimizations() {
@@ -68,8 +72,6 @@ class LintPassConfig extends PassConfig.PassConfigDelegate {
new CheckPrimitiveAsObject(compiler),
new ClosureCheckModule(compiler),
new CheckRequiresAndProvidesSorted(compiler),
- new CheckMissingAndExtraRequires(
- compiler, CheckMissingAndExtraRequires.Mode.SINGLE_FILE),
new CheckSideEffects(
compiler, /* report */ true, /* protectSideEffectFreeCode */ false),
new CheckUnusedLabels(compiler),
@@ -96,6 +98,20 @@ class LintPassConfig extends PassConfig.PassConfigDelegate {
}
};
+ private final PassFactory checkRequires =
+ new PassFactory("checkMissingAndExtraRequires", true) {
+ @Override
+ protected CompilerPass create(AbstractCompiler compiler) {
+ return new CheckMissingAndExtraRequires(
+ compiler, CheckMissingAndExtraRequires.Mode.SINGLE_FILE);
+ }
+
+ @Override
+ protected FeatureSet featureSet() {
+ return FeatureSet.latest().withoutTypes();
+ }
+ };
+
private final PassFactory closureRewriteClass =
new PassFactory(PassNames.CLOSURE_REWRITE_CLASS, true) {
@Override
