diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php
index 9225712..16f6d91 100644
--- a/core/lib/Drupal/Core/Template/TwigEnvironment.php
+++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php
@@ -115,12 +115,7 @@ public function loadTemplate($name, $index = NULL) {
     if (!class_exists($cls, FALSE)) {
       $cache_filename = $this->getCacheFilename($name);
 
-      if ($cache_filename === FALSE) {
-        $compiled_source = $this->compileSource($this->loader->getSource($name), $name);
-        eval('?' . '>' . $compiled_source);
-      }
-      else {
-
+      if ($cache_filename !== FALSE) {
         // If autoreload is on, check that the template has not been
         // modified since the last compilation.
         if ($this->isAutoReload() && !$this->isFresh($cache_filename, $name)) {
@@ -132,6 +127,10 @@ public function loadTemplate($name, $index = NULL) {
           $this->storage()->load($cache_filename);
         }
       }
+      if (!class_exists($cls, FALSE)) {
+        $compiled_source = $this->compileSource($this->loader->getSource($name), $name);
+        eval('?' . '>' . $compiled_source);
+      }
     }
 
     if (!$this->runtimeInitialized) {
