From 3db6fd0a8030615b9083f7a7e8915421d3f83605 Mon Sep 17 00:00:00 2001 From: Roberto Lublinerman Date: Tue, 21 Jan 2025 12:35:34 -0800 Subject: [PATCH] [WASM] Run the `VerifyNormalizedUnits` at the end of the modular pipeline. PiperOrigin-RevId: 718027604 --- .../java/com/google/j2cl/transpiler/backend/Backend.java | 7 ++----- .../j2cl/transpiler/passes/VerifyNormalizedUnits.java | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/transpiler/java/com/google/j2cl/transpiler/backend/Backend.java b/transpiler/java/com/google/j2cl/transpiler/backend/Backend.java index e518d089b3..d721c131bc 100644 --- a/transpiler/java/com/google/j2cl/transpiler/backend/Backend.java +++ b/transpiler/java/com/google/j2cl/transpiler/backend/Backend.java @@ -674,11 +674,8 @@ public ImmutableList> getPassFactories(BackendOption // Post-verifications VerifySingleAstReference::new, VerifyParamAndArgCounts::new, - VerifyReferenceScoping::new - - // TODO(b/283154833): Add the invariants for modular_wasm - // () -> new VerifyNormalizedUnits(/* verifyForWasm= **/ true) - ); + VerifyReferenceScoping::new, + () -> new VerifyNormalizedUnits(/* verifyForWasm= **/ true)); } @Override diff --git a/transpiler/java/com/google/j2cl/transpiler/passes/VerifyNormalizedUnits.java b/transpiler/java/com/google/j2cl/transpiler/passes/VerifyNormalizedUnits.java index df84e54ae3..ec05112f55 100644 --- a/transpiler/java/com/google/j2cl/transpiler/passes/VerifyNormalizedUnits.java +++ b/transpiler/java/com/google/j2cl/transpiler/passes/VerifyNormalizedUnits.java @@ -309,8 +309,10 @@ public void exitSwitchExpression(SwitchExpression switchExpression) { @Override public void exitYieldStatement(YieldStatement yieldStatement) { - // Yield statements are expected to be normalized away. - throw new IllegalStateException(); + if (!verifyForWasm) { + // Yield statements are expected to be normalized away. + throw new IllegalStateException(); + } } @Override