From b9519f92f8ce096107164ca5075feced0e989de7 Mon Sep 17 00:00:00 2001 From: jcater Date: Thu, 8 Apr 2021 13:17:21 -0700 Subject: [PATCH] Make StarlarkExecGroupContext use AutoValue. This gives reasonable equals and hashCode behavior. PiperOrigin-RevId: 367493368 --- .../starlark/StarlarkExecGroupCollection.java | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkExecGroupCollection.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkExecGroupCollection.java index 17e5652840990b..e360a1c2469020 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkExecGroupCollection.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkExecGroupCollection.java @@ -82,7 +82,7 @@ public StarlarkExecGroupContext getIndex(StarlarkSemantics semantics, Object key String.join(", ", getScrubbedExecGroups())); } ToolchainContextApi toolchainContext = toolchainCollection().getToolchainContext(execGroup); - return new StarlarkExecGroupContext(toolchainContext); + return new AutoValue_StarlarkExecGroupCollection_StarlarkExecGroupContext(toolchainContext); } private static String castGroupName(Object key) throws EvalException { @@ -113,17 +113,10 @@ private List getScrubbedExecGroups() { * The starlark object that is returned by ctx.exec_groups[]. Gives information about that * exec group. */ - public static class StarlarkExecGroupContext implements ExecGroupContextApi { - ToolchainContextApi toolchainContext; - - private StarlarkExecGroupContext(ToolchainContextApi toolchainContext) { - this.toolchainContext = toolchainContext; - } - + @AutoValue + public abstract static class StarlarkExecGroupContext implements ExecGroupContextApi { @Override - public ToolchainContextApi toolchains() { - return toolchainContext; - } + public abstract ToolchainContextApi toolchains(); @Override public void repr(Printer printer) {