Returning version injection from File to FileState.

This is mostly a rollback of https://github.com/bazelbuild/bazel/commit/9394099d4e14c54cb0c5016bc49c5cd79a9ef427, however due to a number of other necessary changes that are included, I thought it made more sense to not be a rollback CL.

RELNOTES: None.
PiperOrigin-RevId: 220519676
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index 4bbba05..e0b3572 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -434,13 +434,13 @@
     map.put(SkyFunctions.PRECOMPUTED, new PrecomputedFunction());
     map.put(SkyFunctions.CLIENT_ENVIRONMENT_VARIABLE, new ClientEnvironmentFunction(clientEnv));
     map.put(SkyFunctions.ACTION_ENVIRONMENT_VARIABLE, new ActionEnvironmentFunction());
-    map.put(FileStateValue.FILE_STATE, new FileStateFunction(tsgm, externalFilesHelper));
+    map.put(FileStateValue.FILE_STATE, newFileStateFunction());
     map.put(SkyFunctions.DIRECTORY_LISTING_STATE, newDirectoryListingStateFunction());
     map.put(SkyFunctions.FILE_SYMLINK_CYCLE_UNIQUENESS,
         new FileSymlinkCycleUniquenessFunction());
     map.put(SkyFunctions.FILE_SYMLINK_INFINITE_EXPANSION_UNIQUENESS,
         new FileSymlinkInfiniteExpansionUniquenessFunction());
-    map.put(FileValue.FILE, newFileFunction());
+    map.put(FileValue.FILE, new FileFunction(pkgLocator, nonexistentFileReceiver));
     map.put(SkyFunctions.DIRECTORY_LISTING, new DirectoryListingFunction());
     map.put(
         SkyFunctions.PACKAGE_LOOKUP,
@@ -578,8 +578,8 @@
     return false;
   }
 
-  protected SkyFunction newFileFunction() {
-    return new FileFunction(pkgLocator, nonexistentFileReceiver);
+  protected SkyFunction newFileStateFunction() {
+    return new FileStateFunction(tsgm, externalFilesHelper);
   }
 
   protected SkyFunction newDirectoryListingStateFunction() {
diff --git a/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java b/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java
index 9f062da..bab736e 100644
--- a/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java
+++ b/src/main/java/com/google/devtools/build/skyframe/SkyFunctionEnvironment.java
@@ -838,8 +838,7 @@
 
   @Override
   public void injectVersionForNonHermeticFunction(Version version) {
-    // TODO(jhorvitz): Make this check stricter (== NONHERMETIC) after callers are migrated.
-    Preconditions.checkState(hermeticity != FunctionHermeticity.HERMETIC, skyKey);
+    Preconditions.checkState(hermeticity == FunctionHermeticity.NONHERMETIC, skyKey);
     injectedVersion = version;
   }