22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- import 'package:analyzer/dart/analysis/declared_variables.dart' ;
65import 'package:analyzer/dart/ast/syntactic_entity.dart' ;
76import 'package:analyzer/dart/ast/token.dart' ;
87import 'package:analyzer/dart/ast/visitor.dart' ;
@@ -13,8 +12,6 @@ import 'package:analyzer/dart/element/type.dart';
1312import 'package:analyzer/error/listener.dart' ;
1413import 'package:analyzer/src/dart/ast/ast.dart' ;
1514import 'package:analyzer/src/dart/ast/extensions.dart' ;
16- import 'package:analyzer/src/dart/constant/evaluation.dart' ;
17- import 'package:analyzer/src/dart/constant/value.dart' ;
1815import 'package:analyzer/src/dart/element/element.dart' ;
1916import 'package:analyzer/src/dart/element/type.dart' ;
2017import 'package:analyzer/src/dart/element/type_system.dart' ;
@@ -109,24 +106,15 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
109106 /// Subclass of `Struct` or `Union` we are currently visiting, or `null` .
110107 ClassDeclaration ? compound;
111108
112- final LibraryElementImpl _currentLibrary;
113-
114- final ConstantEvaluationEngine _evaluationEngine;
115-
116109 /// The `Void` type from `dart:ffi` , or `null` if unresolved.
117110 InterfaceTypeImpl ? ffiVoidType;
118111
119112 /// Initialize a newly created verifier.
120113 FfiVerifier (
121114 this .typeSystem,
122- this ._diagnosticReporter,
123- this ._currentLibrary,
124- DeclaredVariables declaredVariables, {
115+ this ._diagnosticReporter, {
125116 required this .strictCasts,
126- }) : _evaluationEngine = ConstantEvaluationEngine (
127- declaredVariables: declaredVariables,
128- configuration: ConstantEvaluationConfiguration (),
129- );
117+ });
130118
131119 @override
132120 void visitClassDeclaration (covariant ClassDeclarationImpl node) {
@@ -756,17 +744,8 @@ class FfiVerifier extends RecursiveAstVisitor<void> {
756744 }
757745
758746 bool _isConst (Expression expr) {
759- var subDiagnosticReporter = DiagnosticReporter (
760- RecordingDiagnosticListener (),
761- _diagnosticReporter.source,
762- );
763- var constantVisitor = ConstantVisitor (
764- _evaluationEngine,
765- _currentLibrary,
766- subDiagnosticReporter,
767- );
768- var result = constantVisitor.evaluateConstant (expr);
769- return result is ! InvalidConstant ;
747+ var computedConstant = expr.computeConstantValue ();
748+ return computedConstant? .value != null ;
770749 }
771750
772751 bool _isLeaf (NodeList <Expression >? args) {
0 commit comments