Automated rollback of commit f309ad3be36363070e87eef0ee04b12f4956d601.

*** Reason for rollback ***

Fixed duplicate derived inputs bug. Test is in diffbase.

RELNOTES[INC]: If the same artifact is generated by two distinct but identical actions, and a downstream action has both those actions' outputs in its inputs, the artifact will now appear twice in the downstream action's inputs. If this causes problems in Skylark actions, you can use the uniquify=True argument in Args.add_args.

PiperOrigin-RevId: 205863806
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
index 3587f08..467391a 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactFunction.java
@@ -54,11 +54,11 @@
   @Override
   public SkyValue compute(SkyKey skyKey, Environment env)
       throws ArtifactFunctionException, InterruptedException {
-    ArtifactSkyKey artifactSkyKey = (ArtifactSkyKey) skyKey.argument();
-    Artifact artifact = artifactSkyKey.getArtifact();
+    Artifact artifact = ArtifactSkyKey.artifact(skyKey);
+    boolean isMandatory = ArtifactSkyKey.isMandatory(skyKey);
     if (artifact.isSourceArtifact()) {
       try {
-        return createSourceValue(artifact, artifactSkyKey.isMandatory(), env);
+        return createSourceValue(artifact, isMandatory, env);
       } catch (MissingInputFileException e) {
         // The error is not necessarily truly transient, but we mark it as such because we have
         // the above side effect of posting an event to the EventBus. Importantly, that event
@@ -281,8 +281,7 @@
       throws InterruptedException {
     // This artifact aggregates other artifacts. Keep track of them so callers can find them.
     ImmutableList.Builder<Pair<Artifact, FileArtifactValue>> inputs = ImmutableList.builder();
-    for (Map.Entry<SkyKey, SkyValue> entry :
-        env.getValues(ArtifactSkyKey.mandatoryKeys(action.getInputs())).entrySet()) {
+    for (Map.Entry<SkyKey, SkyValue> entry : env.getValues(action.getInputs()).entrySet()) {
       Artifact input = ArtifactSkyKey.artifact(entry.getKey());
       SkyValue inputValue = entry.getValue();
       if (inputValue == null) {
@@ -323,7 +322,7 @@
 
   @Override
   public String extractTag(SkyKey skyKey) {
-    return Label.print(((ArtifactSkyKey) skyKey.argument()).getArtifact().getOwner());
+    return Label.print(ArtifactSkyKey.artifact(skyKey).getOwner());
   }
 
   static ActionLookupKey getActionLookupKey(Artifact artifact) {