Fixed a bug with dirty node handling.

We used to share a single instance of ArtifactNestedSetValue among all the
NodeEntry for ArtifactNestedSetKey. That's a problem for propagating the dirty
status along the reversed dependency edges (because of the SkyValue remains the
same, the propagation is stopped).

RELNOTES: None
PiperOrigin-RevId: 281281501
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetFunction.java
index 65db987..40e4d46 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetFunction.java
@@ -117,7 +117,7 @@
 
     // Only commit to the map when every value is present.
     artifactSkyKeyToValueOrException.putAll(directArtifactsEvalResult);
-    return ArtifactNestedSetValue.createOrGetInstance();
+    return new ArtifactNestedSetValue();
   }
 
   public static ArtifactNestedSetFunction getInstance() {
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetValue.java b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetValue.java
index 452b9d6..882dd9d 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetValue.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ArtifactNestedSetValue.java
@@ -24,13 +24,4 @@
 @Immutable
 @ThreadSafe
 public class ArtifactNestedSetValue implements SkyValue {
-
-  private static ArtifactNestedSetValue singleton = null;
-
-  static ArtifactNestedSetValue createOrGetInstance() {
-    if (singleton == null) {
-      singleton = new ArtifactNestedSetValue();
-    }
-    return singleton;
-  }
 }
diff --git a/src/test/shell/integration/experimental_nestedset_as_skykey_tests.sh b/src/test/shell/integration/experimental_nestedset_as_skykey_tests.sh
index 563b12a..018af59 100755
--- a/src/test/shell/integration/experimental_nestedset_as_skykey_tests.sh
+++ b/src/test/shell/integration/experimental_nestedset_as_skykey_tests.sh
@@ -203,5 +203,41 @@
   [[ $regular == $back_to_zero ]] || fail "number of nodes and edges on skyframe should be the same"
 }
 
+function test_experimental_nested_set_as_skykey_dirty_file() {
+  export DONT_SANITY_CHECK_SERIALIZATION=1
+  cat > foo/BUILD <<EOF
+load(":foo.bzl", "foo_library", "foo_binary")
+py_binary(
+    name = "foocc",
+    srcs = ["foocc.py"],
+)
+
+foo_library(
+    name = "a",
+    srcs = ["1.a"],
+)
+
+foo_library(
+    name = "b",
+    srcs = ["1.b"],
+    deps = [":a"],
+)
+foo_binary(
+    name = "c",
+    srcs = ["c.foo"],
+    deps = [":b"],
+)
+EOF
+  touch foo/1.a foo/1.b foo/c.foo
+
+  bazel build --experimental_nested_set_as_skykey_threshold=2 //foo:c || fail "build failed"
+  # Deliberately breaking the file.
+  echo omgomgomg >> foo/foocc.py
+  bazel build --experimental_nested_set_as_skykey_threshold=2 //foo:c && fail "Expected failure"
+
+  true  # reset the last exit code so the test won't be considered failed
+}
+
+
 
 run_suite "Integration tests of ${PRODUCT_NAME} with NestedSet as SkyKey."