Add `getMaxTransitiveSourceVersionToInjectForNonHermeticFunction` to `SkyFunction`, which returns the max transitive source version (mtsv) that could be injected via `SkyFunctionEnvironment#injectVersionForNonHermeticFunction` if `#compute` were invoked for a `SkyKey`/`SkyValue` pair, or null if no call for version injection is made.
PiperOrigin-RevId: 526996521
Change-Id: Ie99c41a452e3c67ae9a60546164cafaaac54cc7f
diff --git a/src/main/java/com/google/devtools/build/skyframe/SkyFunction.java b/src/main/java/com/google/devtools/build/skyframe/SkyFunction.java
index 5b6aa3b..9ea7ed5 100644
--- a/src/main/java/com/google/devtools/build/skyframe/SkyFunction.java
+++ b/src/main/java/com/google/devtools/build/skyframe/SkyFunction.java
@@ -13,6 +13,8 @@
// limitations under the License.
package com.google.devtools.build.skyframe;
+import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.base.Preconditions;
import com.google.common.graph.GraphBuilder;
import com.google.common.graph.ImmutableGraph;
@@ -21,6 +23,7 @@
import com.google.devtools.build.lib.events.ExtendedEventHandler;
import com.google.devtools.build.lib.events.Reportable;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
+import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import javax.annotation.Nullable;
@@ -85,6 +88,19 @@
}
/**
+ * Returns the max transitive source version that would be injected via {@link
+ * SkyFunctionEnvironment#injectVersionForNonHermeticFunction} if {@link #compute(SkyKey,
+ * Environment)} were invoked for the given {@link SkyKey}/{@link SkyValue} pair, or null if no
+ * call for version injection would be made.
+ */
+ @Nullable
+ default Version getMaxTransitiveSourceVersionToInjectForNonHermeticFunction(
+ SkyKey skyKey, SkyValue skyValue) throws IOException {
+ checkState(skyKey.functionName().getHermeticity() == FunctionHermeticity.HERMETIC);
+ return null;
+ }
+
+ /**
* Sentinel {@link SkyValue} type for {@link #compute} to return, indicating that something went
* wrong, and that the evaluation returning this value must be restarted, and the nodes associated
* with other keys in {@link #rewindGraph()} (whose directed edges should correspond to the nodes'