Add @CheckReturnValue to turbine packages

PiperOrigin-RevId: 386117171
diff --git a/java/com/google/common/escape/package-info.java b/java/com/google/common/escape/package-info.java
new file mode 100644
index 0000000..1683da4
--- /dev/null
+++ b/java/com/google/common/escape/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.common.escape;
diff --git a/java/com/google/turbine/bytecode/ByteReader.java b/java/com/google/turbine/bytecode/ByteReader.java
index 5458b49..a9deff2 100644
--- a/java/com/google/turbine/bytecode/ByteReader.java
+++ b/java/com/google/turbine/bytecode/ByteReader.java
@@ -20,9 +20,11 @@
 
 import com.google.common.io.ByteArrayDataInput;
 import com.google.common.io.ByteStreams;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import java.io.ByteArrayInputStream;
 
 /** A {@link ByteArrayDataInput} wrapper that tracks the current byte array index. */
+@CanIgnoreReturnValue
 public class ByteReader {
 
   private final byte[] bytes;
diff --git a/java/com/google/turbine/bytecode/package-info.java b/java/com/google/turbine/bytecode/package-info.java
new file mode 100644
index 0000000..03c1664
--- /dev/null
+++ b/java/com/google/turbine/bytecode/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.bytecode;
diff --git a/java/com/google/turbine/bytecode/sig/SigParser.java b/java/com/google/turbine/bytecode/sig/SigParser.java
index 033fa18..1bfd762 100644
--- a/java/com/google/turbine/bytecode/sig/SigParser.java
+++ b/java/com/google/turbine/bytecode/sig/SigParser.java
@@ -17,6 +17,7 @@
 package com.google.turbine.bytecode.sig;
 
 import com.google.common.collect.ImmutableList;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import com.google.turbine.bytecode.sig.Sig.ArrayTySig;
 import com.google.turbine.bytecode.sig.Sig.BaseTySig;
 import com.google.turbine.bytecode.sig.Sig.ClassSig;
@@ -46,6 +47,7 @@
   }
 
   /** Returns the next character and advances. */
+  @CanIgnoreReturnValue
   char eat() {
     return sig.charAt(idx++);
   }
diff --git a/java/com/google/turbine/bytecode/sig/package-info.java b/java/com/google/turbine/bytecode/sig/package-info.java
new file mode 100644
index 0000000..9b109a3
--- /dev/null
+++ b/java/com/google/turbine/bytecode/sig/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.bytecode.sig;
diff --git a/java/com/google/turbine/deps/package-info.java b/java/com/google/turbine/deps/package-info.java
new file mode 100644
index 0000000..28df5a9
--- /dev/null
+++ b/java/com/google/turbine/deps/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.deps;
diff --git a/java/com/google/turbine/diag/package-info.java b/java/com/google/turbine/diag/package-info.java
new file mode 100644
index 0000000..f19a95c
--- /dev/null
+++ b/java/com/google/turbine/diag/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.diag;
diff --git a/java/com/google/turbine/lower/package-info.java b/java/com/google/turbine/lower/package-info.java
new file mode 100644
index 0000000..f5c54fc
--- /dev/null
+++ b/java/com/google/turbine/lower/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.lower;
diff --git a/java/com/google/turbine/main/Main.java b/java/com/google/turbine/main/Main.java
index 59563b6..f287267 100644
--- a/java/com/google/turbine/main/Main.java
+++ b/java/com/google/turbine/main/Main.java
@@ -24,6 +24,7 @@
 import com.google.common.collect.ImmutableMap;
 import com.google.common.hash.Hashing;
 import com.google.common.io.MoreFiles;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import com.google.turbine.binder.Binder;
 import com.google.turbine.binder.Binder.BindingResult;
 import com.google.turbine.binder.Binder.Statistics;
@@ -126,10 +127,12 @@
     }
   }
 
-  public static void compile(String[] args) throws IOException {
-    compile(TurbineOptionsParser.parse(Arrays.asList(args)));
+  @CanIgnoreReturnValue
+  public static Result compile(String[] args) throws IOException {
+    return compile(TurbineOptionsParser.parse(Arrays.asList(args)));
   }
 
+  @CanIgnoreReturnValue
   public static Result compile(TurbineOptions options) throws IOException {
     usage(options);
 
diff --git a/java/com/google/turbine/main/package-info.java b/java/com/google/turbine/main/package-info.java
new file mode 100644
index 0000000..71735f2
--- /dev/null
+++ b/java/com/google/turbine/main/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.main;
diff --git a/java/com/google/turbine/model/package-info.java b/java/com/google/turbine/model/package-info.java
new file mode 100644
index 0000000..a1e3873
--- /dev/null
+++ b/java/com/google/turbine/model/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.model;
diff --git a/java/com/google/turbine/parse/Parser.java b/java/com/google/turbine/parse/Parser.java
index 40c9cab..77457b7 100644
--- a/java/com/google/turbine/parse/Parser.java
+++ b/java/com/google/turbine/parse/Parser.java
@@ -27,7 +27,7 @@
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
-import com.google.errorprone.annotations.CheckReturnValue;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import com.google.turbine.diag.SourceFile;
 import com.google.turbine.diag.TurbineError;
 import com.google.turbine.diag.TurbineError.ErrorKind;
@@ -1407,6 +1407,7 @@
     next();
   }
 
+  @CanIgnoreReturnValue
   private boolean maybe(Token kind) {
     if (token == kind) {
       next();
@@ -1415,7 +1416,6 @@
     return false;
   }
 
-  @CheckReturnValue
   TurbineError error(Token token) {
     switch (token) {
       case IDENT:
@@ -1427,7 +1427,6 @@
     }
   }
 
-  @CheckReturnValue
   private TurbineError error(ErrorKind kind, Object... args) {
     return TurbineError.format(
         lexer.source(),
diff --git a/java/com/google/turbine/parse/package-info.java b/java/com/google/turbine/parse/package-info.java
new file mode 100644
index 0000000..ace7dcf
--- /dev/null
+++ b/java/com/google/turbine/parse/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.parse;
diff --git a/java/com/google/turbine/processing/package-info.java b/java/com/google/turbine/processing/package-info.java
new file mode 100644
index 0000000..abf6732
--- /dev/null
+++ b/java/com/google/turbine/processing/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.processing;
diff --git a/java/com/google/turbine/tree/Pretty.java b/java/com/google/turbine/tree/Pretty.java
index b693a42..7e90046 100644
--- a/java/com/google/turbine/tree/Pretty.java
+++ b/java/com/google/turbine/tree/Pretty.java
@@ -20,6 +20,7 @@
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
 import com.google.turbine.tree.Tree.Anno;
 import com.google.turbine.tree.Tree.ClassLiteral;
 import com.google.turbine.tree.Tree.Ident;
@@ -60,6 +61,7 @@
     newLine = true;
   }
 
+  @CanIgnoreReturnValue
   Pretty append(char c) {
     if (c == '\n') {
       newLine = true;
@@ -71,6 +73,7 @@
     return this;
   }
 
+  @CanIgnoreReturnValue
   Pretty append(String s) {
     if (newLine) {
       sb.append(Strings.repeat(" ", indent * 2));
diff --git a/java/com/google/turbine/tree/package-info.java b/java/com/google/turbine/tree/package-info.java
new file mode 100644
index 0000000..e400f40
--- /dev/null
+++ b/java/com/google/turbine/tree/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.tree;
diff --git a/java/com/google/turbine/type/package-info.java b/java/com/google/turbine/type/package-info.java
new file mode 100644
index 0000000..2329130
--- /dev/null
+++ b/java/com/google/turbine/type/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.type;
diff --git a/java/com/google/turbine/types/package-info.java b/java/com/google/turbine/types/package-info.java
new file mode 100644
index 0000000..fd541d7
--- /dev/null
+++ b/java/com/google/turbine/types/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.types;
diff --git a/java/com/google/turbine/zip/package-info.java b/java/com/google/turbine/zip/package-info.java
new file mode 100644
index 0000000..069e5e1
--- /dev/null
+++ b/java/com/google/turbine/zip/package-info.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright 2021 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@com.google.errorprone.annotations.CheckReturnValue
+package com.google.turbine.zip;
diff --git a/javatests/com/google/turbine/processing/TurbineFilerTest.java b/javatests/com/google/turbine/processing/TurbineFilerTest.java
index d433428..cb94994 100644
--- a/javatests/com/google/turbine/processing/TurbineFilerTest.java
+++ b/javatests/com/google/turbine/processing/TurbineFilerTest.java
@@ -100,9 +100,9 @@
 
     assertThrows(
         FilerException.class, () -> filer.createSourceFile("com.foo.Bar", (Element[]) null));
-    filer.createSourceFile("com.foo.Baz", (Element[]) null);
+    JavaFileObject unused = filer.createSourceFile("com.foo.Baz", (Element[]) null);
 
-    filer.createClassFile("com.foo.Bar", (Element[]) null);
+    unused = filer.createClassFile("com.foo.Bar", (Element[]) null);
     assertThrows(
         FilerException.class, () -> filer.createClassFile("com.foo.Baz", (Element[]) null));
   }
@@ -125,7 +125,7 @@
     try (Writer writer = classFile.openWriter()) {
       writer.write("hello");
     }
-    filer.finishRound();
+    Collection<SourceFile> unused = filer.finishRound();
 
     FileObject output = filer.getResource(StandardLocation.SOURCE_OUTPUT, "com.foo", "Bar.java");
     assertThat(new String(ByteStreams.toByteArray(output.openInputStream()), UTF_8))
@@ -140,7 +140,7 @@
     try (OutputStream os = classFile.openOutputStream()) {
       os.write("goodbye".getBytes(UTF_8));
     }
-    filer.finishRound();
+    Collection<SourceFile> unused = filer.finishRound();
 
     FileObject output = filer.getResource(StandardLocation.CLASS_OUTPUT, "com.foo", "Baz.class");
     assertThat(new String(ByteStreams.toByteArray(output.openInputStream()), UTF_8))