Clean up some non-driver code in constant evaluation

Change-Id: I52a25e053fc9cc5e71bd414f615be54e5da5299d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/lib/src/dart/constant/compute.dart b/pkg/analyzer/lib/src/dart/constant/compute.dart
index 712d4b6..43dbc77 100644
--- a/pkg/analyzer/lib/src/dart/constant/compute.dart
+++ b/pkg/analyzer/lib/src/dart/constant/compute.dart
@@ -20,9 +20,7 @@
     ExperimentStatus experimentStatus) {
   var evaluationEngine = ConstantEvaluationEngine(
       typeProvider, declaredVariables,
-      forAnalysisDriver: true,
-      typeSystem: typeSystem,
-      experimentStatus: experimentStatus);
+      typeSystem: typeSystem, experimentStatus: experimentStatus);
 
   var nodes = <_ConstantNode>[];
   var nodeMap = <ConstantEvaluationTarget, _ConstantNode>{};
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index 55e3ef0..26fc896 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -46,19 +46,17 @@
   final ConstantEvaluationEngine _evaluationEngine;
 
   /// Initialize a newly created constant verifier.
-  ///
-  /// @param errorReporter the error reporter by which errors will be reported
-  ///
-  /// TODO(paulberry): make [featureSet] a required parameter.
   ConstantVerifier(ErrorReporter errorReporter, LibraryElement currentLibrary,
       TypeProvider typeProvider, DeclaredVariables declaredVariables,
-      {bool forAnalysisDriver: false, FeatureSet featureSet})
+      // TODO(brianwilkerson) Remove the unused parameter `forAnalysisDriver`.
+      {bool forAnalysisDriver,
+      // TODO(paulberry): make [featureSet] a required parameter.
+      FeatureSet featureSet})
       : this._(
             errorReporter,
             currentLibrary,
             typeProvider,
             declaredVariables,
-            forAnalysisDriver,
             currentLibrary.context.typeSystem,
             featureSet ??
                 (currentLibrary.context.analysisOptions as AnalysisOptionsImpl)
@@ -69,7 +67,6 @@
       this._currentLibrary,
       this._typeProvider,
       this.declaredVariables,
-      bool forAnalysisDriver,
       TypeSystem typeSystem,
       FeatureSet featureSet)
       : _constantUpdate2018Enabled =
@@ -77,9 +74,7 @@
         _intType = _typeProvider.intType,
         _evaluationEngine = new ConstantEvaluationEngine(
             _typeProvider, declaredVariables,
-            forAnalysisDriver: forAnalysisDriver,
-            typeSystem: typeSystem,
-            experimentStatus: featureSet);
+            typeSystem: typeSystem, experimentStatus: featureSet);
 
   @override
   void visitAnnotation(Annotation node) {
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 6633be9..bac1408 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -98,11 +98,6 @@
   final ConstantEvaluationValidator validator;
 
   /**
-   * Whether this engine is used inside Analysis Driver.
-   */
-  final bool forAnalysisDriver;
-
-  /**
    * Initialize a newly created [ConstantEvaluationEngine].  The [typeProvider]
    * is used to access known types.  [_declaredVariables] is the set of
    * variables declared on the command line using '-D'.  The [validator], if
@@ -113,7 +108,8 @@
       {ConstantEvaluationValidator validator,
       ExperimentStatus experimentStatus,
       TypeSystem typeSystem,
-      this.forAnalysisDriver: false})
+      // TODO(brianwilkerson) Remove the unused parameter `forAnalysisDriver`.
+      @deprecated bool forAnalysisDriver})
       : typeProvider = typeProvider,
         validator =
             validator ?? new ConstantEvaluationValidator_ForProduction(),
@@ -1016,7 +1012,8 @@
  */
 class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
   /**
-   * The type provider used to access the known types.
+   * The evaluation engine used to access the feature set, type system, and type
+   * provider.
    */
   final ConstantEvaluationEngine evaluationEngine;
 
@@ -1714,23 +1711,13 @@
         element is PropertyAccessorElement ? element.variable : element;
     if (variableElement is VariableElementImpl) {
       // We access values of constant variables here in two cases: when we
-      // compute values of other constant  variables, or when we compute values
-      // and errors for other constant expressions. In any case, with Analysis
-      // Driver, we compute values of all dependencies first (or detect  cycle).
-      // So, the value has already been computed. Just return it.
-      if (evaluationEngine.forAnalysisDriver) {
-        EvaluationResultImpl value = variableElement.evaluationResult;
-        if (variableElement.isConst && value != null) {
-          return value.value;
-        }
-      } else {
-        // TODO(scheglov) Once we remove task model, we can remove this code.
-        evaluationEngine.validator.beforeGetEvaluationResult(variableElement);
-        variableElement.computeConstantValue();
-        EvaluationResultImpl value = variableElement.evaluationResult;
-        if (variableElement.isConst && value != null) {
-          return value.value;
-        }
+      // compute values of other constant variables, or when we compute values
+      // and errors for other constant expressions. In either case we have
+      // already computed values of all dependencies first (or detect a cycle),
+      // so the value has already been computed and we can just return it.
+      EvaluationResultImpl value = variableElement.evaluationResult;
+      if (variableElement.isConst && value != null) {
+        return value.value;
       }
     } else if (variableElement is ExecutableElement) {
       ExecutableElement function = element;
@@ -1801,7 +1788,7 @@
   final ErrorReporter _errorReporter;
 
   /**
-   * The type provider used to access the known types.
+   * The evaluation engine used to access the type system, and type provider.
    */
   final ConstantEvaluationEngine _evaluationEngine;