From e1ea3c5130b465ea8079d03e7cc68ebb44af32ae Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Tue, 10 Sep 2024 13:07:34 -0700 Subject: [PATCH] Fix parsing of `module-info` `require` directives that are both `static` and `transitive` PiperOrigin-RevId: 673075838 --- java/com/google/turbine/parse/Parser.java | 4 ++-- .../com/google/turbine/lower/ModuleIntegrationTest.java | 2 ++ .../moduletestdata/module-requires-static-transitive.test | 5 +++++ .../moduletestdata/module-requires-transitive-static.test | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 javatests/com/google/turbine/lower/moduletestdata/module-requires-static-transitive.test create mode 100644 javatests/com/google/turbine/lower/moduletestdata/module-requires-transitive-static.test diff --git a/java/com/google/turbine/parse/Parser.java b/java/com/google/turbine/parse/Parser.java index 67c50241..7fed6666 100644 --- a/java/com/google/turbine/parse/Parser.java +++ b/java/com/google/turbine/parse/Parser.java @@ -464,12 +464,12 @@ private ModRequires moduleRequires() { if (token == Token.IDENT && lexer.stringValue().equals("transitive")) { next(); access.add(TurbineModifier.TRANSITIVE); - break; + continue; } if (token == Token.STATIC) { next(); access.add(TurbineModifier.STATIC); - break; + continue; } break; } diff --git a/javatests/com/google/turbine/lower/ModuleIntegrationTest.java b/javatests/com/google/turbine/lower/ModuleIntegrationTest.java index 7cc7952e..a185781e 100644 --- a/javatests/com/google/turbine/lower/ModuleIntegrationTest.java +++ b/javatests/com/google/turbine/lower/ModuleIntegrationTest.java @@ -48,6 +48,8 @@ public static Iterable parameters() { "classpath.test", "multimodule.test", "module-info-open.test", + "module-requires-static-transitive.test", + "module-requires-transitive-static.test", }; return ImmutableList.copyOf(testCases).stream().map(x -> new Object[] {x}).collect(toList()); } diff --git a/javatests/com/google/turbine/lower/moduletestdata/module-requires-static-transitive.test b/javatests/com/google/turbine/lower/moduletestdata/module-requires-static-transitive.test new file mode 100644 index 00000000..84084dc1 --- /dev/null +++ b/javatests/com/google/turbine/lower/moduletestdata/module-requires-static-transitive.test @@ -0,0 +1,5 @@ +=== module-info.java === + +module foo { + requires static transitive java.base; +} \ No newline at end of file diff --git a/javatests/com/google/turbine/lower/moduletestdata/module-requires-transitive-static.test b/javatests/com/google/turbine/lower/moduletestdata/module-requires-transitive-static.test new file mode 100644 index 00000000..33c09118 --- /dev/null +++ b/javatests/com/google/turbine/lower/moduletestdata/module-requires-transitive-static.test @@ -0,0 +1,5 @@ +=== module-info.java === + +module foo { + requires transitive static java.base; +} \ No newline at end of file