@@ -16,7 +16,6 @@ import 'package:analyzer/dart/element/element.dart';
1616import 'package:analyzer/dart/element/element2.dart' ;
1717import 'package:analyzer/dart/element/nullability_suffix.dart' ;
1818import 'package:analyzer/dart/element/type.dart' ;
19- import 'package:analyzer/dart/element/type_provider.dart' ;
2019import 'package:analyzer/error/listener.dart' ;
2120import 'package:analyzer/src/dart/ast/ast.dart' ;
2221import 'package:analyzer/src/dart/ast/extensions.dart' ;
@@ -30,6 +29,7 @@ import 'package:analyzer/src/dart/element/element.dart';
3029import 'package:analyzer/src/dart/element/member.dart' ;
3130import 'package:analyzer/src/dart/element/type.dart' ;
3231import 'package:analyzer/src/dart/element/type_algebra.dart' ;
32+ import 'package:analyzer/src/dart/element/type_provider.dart' ;
3333import 'package:analyzer/src/dart/element/type_system.dart' show TypeSystemImpl;
3434import 'package:analyzer/src/diagnostic/diagnostic.dart' ;
3535import 'package:analyzer/src/error/codes.dart' ;
@@ -182,7 +182,7 @@ class ConstantEvaluationEngine {
182182 // ignore it here.
183183 constant.evaluationResult = null ;
184184 }
185- } else if (element is ConstructorElement &&
185+ } else if (element is ConstructorElementMixin &&
186186 element.isConst &&
187187 constNode.arguments != null ) {
188188 var errorListener = RecordingErrorListener ();
@@ -342,7 +342,7 @@ class ConstantEvaluationEngine {
342342 AstNode node,
343343 List <DartType >? typeArguments,
344344 List <Expression > arguments,
345- ConstructorElement constructor,
345+ ConstructorElementMixin constructor,
346346 ConstantVisitor constantVisitor, {
347347 ConstructorInvocation ? invocation,
348348 }) {
@@ -387,7 +387,7 @@ class ConstantEvaluationEngine {
387387 AstNode node,
388388 List <DartType >? typeArguments,
389389 List <Expression > arguments,
390- ConstructorElement constructor,
390+ ConstructorElementMixin constructor,
391391 ConstantVisitor constantVisitor, {
392392 ConstructorInvocation ? invocation,
393393 }) {
@@ -446,8 +446,8 @@ class ConstantEvaluationEngine {
446446
447447 /// If [constructor] redirects to another const constructor, return the
448448 /// const constructor it redirects to. Otherwise return `null` .
449- static ConstructorElement ? getConstRedirectedConstructor (
450- ConstructorElement constructor) {
449+ static ConstructorElementMixin ? getConstRedirectedConstructor (
450+ ConstructorElementMixin constructor) {
451451 if (! constructor.isFactory) {
452452 return null ;
453453 }
@@ -500,7 +500,7 @@ class ConstantEvaluationEngine {
500500 /// Returns the representation of a constant expression which has an
501501 /// [InvalidType] , with the given [defaultType] .
502502 static DartObjectImpl _unresolvedObject (
503- LibraryElementImpl library, DartType defaultType) {
503+ LibraryElementImpl library, TypeImpl defaultType) {
504504 // TODO(kallentu): Use a better representation of an unresolved object that
505505 // doesn't need to rely on NullState.
506506 return DartObjectImpl (
@@ -582,7 +582,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
582582 TypeSystemImpl get typeSystem => _library.typeSystem;
583583
584584 /// Convenience getter to access the [_evaluationEngine] 's type provider.
585- TypeProvider get _typeProvider => _library.typeProvider;
585+ TypeProviderImpl get _typeProvider => _library.typeProvider;
586586
587587 /// Evaluates and reports an error if the evaluation result of [node] is an
588588 /// [InvalidConstant] .
@@ -929,7 +929,8 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
929929 }
930930
931931 @override
932- Constant visitInstanceCreationExpression (InstanceCreationExpression node) {
932+ Constant visitInstanceCreationExpression (
933+ covariant InstanceCreationExpressionImpl node) {
933934 if (! node.isConst) {
934935 // TODO(srawlins): Use a specific error code.
935936 // https://github.com/dart-lang/sdk/issues/47061
@@ -1235,7 +1236,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
12351236 }
12361237 }
12371238
1238- var nodeType = RecordType (
1239+ var nodeType = RecordTypeImpl . fromApi (
12391240 positional: positionalFields.map ((e) => e.type).toList (),
12401241 named: namedFields.map ((name, value) => MapEntry (name, value.type)),
12411242 nullabilitySuffix: NullabilitySuffix .none,
@@ -1271,7 +1272,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
12711272 var keyType = _typeProvider.dynamicType;
12721273 var valueType = _typeProvider.dynamicType;
12731274 var nodeType = node.staticType;
1274- if (nodeType is InterfaceType ) {
1275+ if (nodeType is InterfaceTypeImpl ) {
12751276 var typeArguments = nodeType.typeArguments;
12761277 if (typeArguments.length >= 2 ) {
12771278 keyType = typeArguments[0 ];
@@ -1364,7 +1365,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
13641365 List <DartObjectImpl > list,
13651366 List <CollectionElement > elements,
13661367 TypeSystemImpl typeSystem,
1367- InterfaceType listType,
1368+ InterfaceTypeImpl listType,
13681369 ) {
13691370 for (var element in elements) {
13701371 switch (element) {
@@ -1458,7 +1459,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
14581459 Map <DartObjectImpl , DartObjectImpl > map,
14591460 List <CollectionElement > elements,
14601461 TypeSystemImpl typeSystem,
1461- InterfaceType mapType,
1462+ InterfaceTypeImpl mapType,
14621463 ) {
14631464 for (var element in elements) {
14641465 switch (element) {
@@ -1552,7 +1553,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
15521553 Set <DartObjectImpl > set ,
15531554 List <CollectionElement > elements,
15541555 TypeSystemImpl typeSystem,
1555- InterfaceType setType,
1556+ InterfaceTypeImpl setType,
15561557 ) {
15571558 for (var element in elements) {
15581559 switch (element) {
@@ -1929,7 +1930,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
19291930 DartObjectImpl _instantiateFunctionType (
19301931 FunctionReference node, DartObjectImpl value) {
19311932 var functionElement = value.toFunctionValue ();
1932- if (functionElement is ! ExecutableElement ) {
1933+ if (functionElement is ! ExecutableElementOrMember ) {
19331934 return value;
19341935 }
19351936 var valueType = functionElement.type;
@@ -1941,7 +1942,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
19411942 var substitution = _substitution;
19421943 if (substitution != null ) {
19431944 instantiatedType =
1944- substitution.substituteType (instantiatedType) as FunctionType ;
1945+ substitution.substituteType (instantiatedType) as FunctionTypeImpl ;
19451946 }
19461947 return value.typeInstantiate (
19471948 typeSystem, instantiatedType, typeArgumentTypes);
@@ -1959,7 +1960,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
19591960 // TODO(srawlins): When all code uses [FunctionReference]s generated via
19601961 // generic function instantiation, remove this method and all call sites.
19611962 var functionElement = value.toFunctionValue ();
1962- if (functionElement is ! ExecutableElement ) {
1963+ if (functionElement is ! ExecutableElementOrMember ) {
19631964 return value;
19641965 }
19651966 var valueType = functionElement.type;
@@ -1992,7 +1993,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
19921993
19931994 /// Return the value of the given [expression] , or a representation of a fake
19941995 /// constant to continue the evaluation if the expression is unresolved.
1995- Constant _valueOf (Expression expression, DartType defaultType) {
1996+ Constant _valueOf (Expression expression, TypeImpl defaultType) {
19961997 var expressionValue = evaluateConstant (expression);
19971998 switch (expressionValue) {
19981999 // TODO(kallentu): g3 relies on reporting errors found here, but also
@@ -2302,7 +2303,7 @@ class DartObjectComputer {
23022303 TypeArgumentList typeArgumentsErrorNode,
23032304 ) {
23042305 var rawType = function.type;
2305- if (rawType is FunctionType ) {
2306+ if (rawType is FunctionTypeImpl ) {
23062307 if (typeArguments.length != rawType.typeFormals.length) {
23072308 if (node is SimpleIdentifier ) {
23082309 return InvalidConstant .forEntity (typeArgumentsErrorNode,
@@ -2427,7 +2428,7 @@ class _InstanceCreationEvaluator {
24272428 /// The node used for most error reporting.
24282429 final AstNode _errorNode;
24292430
2430- final ConstructorElement _constructor;
2431+ final ConstructorElementMixin _constructor;
24312432
24322433 final List <DartType >? _typeArguments;
24332434
@@ -2466,11 +2467,11 @@ class _InstanceCreationEvaluator {
24662467 _argumentValues = argumentValues,
24672468 _invocation = invocation;
24682469
2469- InterfaceType get definingType => _constructor.returnType;
2470+ InterfaceTypeImpl get definingType => _constructor.returnType;
24702471
24712472 DartObjectImpl ? get firstArgument => _argumentValues[0 ];
24722473
2473- TypeProvider get typeProvider => _library.typeProvider;
2474+ TypeProviderImpl get typeProvider => _library.typeProvider;
24742475
24752476 TypeSystemImpl get typeSystem => _library.typeSystem;
24762477
@@ -2649,7 +2650,7 @@ class _InstanceCreationEvaluator {
26492650 /// `null` . Returns `true` if the arguments are correct, `false` otherwise.
26502651 bool _checkFromEnvironmentArguments (
26512652 List <Expression > arguments,
2652- InterfaceType expectedDefaultValueType,
2653+ InterfaceTypeImpl expectedDefaultValueType,
26532654 ) {
26542655 var argumentCount = arguments.length;
26552656 if (argumentCount < 1 || argumentCount > 2 ) {
@@ -2685,7 +2686,7 @@ class _InstanceCreationEvaluator {
26852686 /// redirecting constructor invocation, an [InvalidConstant] , or an
26862687 /// incomplete state for further evaluation.
26872688 _InitializersEvaluationResult _checkInitializers () {
2688- var constructorBase = _constructor.declaration as ConstructorElementImpl ;
2689+ var constructorBase = _constructor.declaration;
26892690 // If we encounter a superinitializer, store the name of the constructor,
26902691 // and the arguments.
26912692 String ? superName;
@@ -2876,9 +2877,7 @@ class _InstanceCreationEvaluator {
28762877 // are handling an optional parameter that wasn't specified. So just
28772878 // direct error messages to the constructor call.
28782879 errorTarget ?? = _errorNode;
2879- if (argumentValue == null &&
2880- baseParameter is ParameterElementImpl &&
2881- baseParameter.isOptional) {
2880+ if (argumentValue == null && baseParameter.isOptional) {
28822881 // The parameter is an optional positional parameter for which no value
28832882 // was provided, so use the default value.
28842883 var evaluationResult = baseParameter.evaluationResult;
@@ -3056,7 +3055,7 @@ class _InstanceCreationEvaluator {
30563055 DeclaredVariables declaredVariables,
30573056 LibraryElementImpl library,
30583057 AstNode node,
3059- ConstructorElement constructor,
3058+ ConstructorElementMixin constructor,
30603059 List <DartType >? typeArguments,
30613060 List <Expression > arguments,
30623061 ConstantVisitor constantVisitor, {
@@ -3074,7 +3073,7 @@ class _InstanceCreationEvaluator {
30743073 node, CompileTimeErrorCode .CONST_WITH_NON_CONST );
30753074 }
30763075
3077- if (! ( constructor.declaration as ConstructorElementImpl ) .isCycleFree) {
3076+ if (! constructor.declaration.isCycleFree) {
30783077 // It's not safe to evaluate this constructor, so bail out.
30793078 //
30803079 // Instead of reporting an error at the call-sites, we will report an
@@ -3095,7 +3094,7 @@ class _InstanceCreationEvaluator {
30953094 // Use the corresponding parameter type as the default value if
30963095 // an unresolved expression is evaluated. We do this to continue the
30973096 // rest of the evaluation without producing unrelated errors.
3098- if (argument is NamedExpression ) {
3097+ if (argument is NamedExpressionImpl ) {
30993098 var parameterType = argument.element? .type ?? InvalidTypeImpl .instance;
31003099 var argumentConstant =
31013100 constantVisitor._valueOf (argument.expression, parameterType);
@@ -3156,8 +3155,8 @@ class _InstanceCreationEvaluator {
31563155 /// chain terminates. If there is a problem (e.g. a redirection can't be
31573156 /// found, or a cycle is encountered), the chain will be followed as far as
31583157 /// possible and then a const factory constructor will be returned.
3159- static ConstructorElement _followConstantRedirectionChain (
3160- ConstructorElement constructor) {
3158+ static ConstructorElementMixin _followConstantRedirectionChain (
3159+ ConstructorElementMixin constructor) {
31613160 var constructorsVisited = < ConstructorElement > {};
31623161 while (true ) {
31633162 var redirectedConstructor =
0 commit comments