Change the initialization of passes so that they don't carry over state between compilation units.
@@ -160,9 +160,19 @@ class J2clTranspiler {
}
private static void normalizeUnits(List<CompilationUnit> j2clUnits) {
+
+ for (CompilationUnit j2clUnit : j2clUnits) {
+ verifyUnit(j2clUnit);
+ for (NormalizationPass pass : getPasses()) {
+ pass.applyTo(j2clUnit);
+ }
+ verifyNormalizedUnit(j2clUnit);
+ }
+ }
+
+ private static ImmutableList<NormalizationPass> getPasses() {
// TODO(b/117155139): Review the ordering of passes.
- List<NormalizationPass> passes =
- ImmutableList.of(
+ return ImmutableList.of(
// Class structure normalizations.
new ImplementLambdaExpressions(),
new OptimizeAnonymousInnerClassesToFunctionExpressions(),
@@ -261,14 +271,6 @@ class J2clTranspiler {
// Enrich source mapping information for better stack deobfuscation.
new FilloutMissingSourceMapInformation());
-
- for (CompilationUnit j2clUnit : j2clUnits) {
- verifyUnit(j2clUnit);
- for (NormalizationPass pass : passes) {
- pass.applyTo(j2clUnit);
- }
- verifyNormalizedUnit(j2clUnit);
- }
}
private static void verifyUnit(CompilationUnit j2clUnit) {
