Skip to content

Commit bdc01d1

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Stop using ConstructorElementMixin in constants evaluation.
Change-Id: I54e22bd9a0068ffa8de5a7ded932131327f672fa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437105 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 78b2708 commit bdc01d1

File tree

6 files changed

+184
-115
lines changed

6 files changed

+184
-115
lines changed

pkg/analyzer/lib/src/dart/constant/compute.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ class _ConstantWalker extends graph.DependencyWalker<_ConstantNode> {
6767
var constantsInCycle = scc.map((node) => node.constant);
6868
for (var node in scc) {
6969
var constant = node.constant;
70-
if (constant is ConstructorFragmentImpl) {
71-
constant.isCycleFree = false;
70+
if (constant is ConstructorElementImpl) {
71+
// TODO(scheglov): move the flag to the element
72+
constant.firstFragment.isCycleFree = false;
7273
}
7374
_getEvaluationEngine(node).generateCycleError(constantsInCycle, constant);
7475
}

pkg/analyzer/lib/src/dart/constant/constant_verifier.dart

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import 'package:analyzer/src/diagnostic/diagnostic_factory.dart';
3333
import 'package:analyzer/src/error/codes.dart';
3434
import 'package:analyzer/src/generated/exhaustiveness.dart';
3535
import 'package:analyzer/src/utilities/extensions/ast.dart';
36-
import 'package:analyzer/src/utilities/extensions/element.dart';
3736

3837
/// Instances of the class `ConstantVerifier` traverse an AST structure looking
3938
/// for additional errors and warnings not covered by the parser and resolver.
@@ -213,11 +212,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
213212
if (node.isConst) {
214213
var constructor = node.constructorName.element;
215214
if (constructor is ConstructorElementMixin2) {
216-
_validateConstructorInvocation(
217-
node,
218-
constructor.asElement,
219-
node.argumentList,
220-
);
215+
_validateConstructorInvocation(node, constructor, node.argumentList);
221216
}
222217
} else {
223218
super.visitDotShorthandConstructorInvocation(node);
@@ -288,7 +283,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
288283
CompileTimeErrorCode.CONST_WITH_TYPE_PARAMETERS,
289284
);
290285

291-
var constructor = node.constructorName.element?.asElement;
286+
var constructor = node.constructorName.element;
292287
if (constructor != null) {
293288
_validateConstructorInvocation(node, constructor, node.argumentList);
294289
}
@@ -916,7 +911,7 @@ class ConstantVerifier extends RecursiveAstVisitor<void> {
916911
/// arguments are constant expressions.
917912
void _validateConstructorInvocation(
918913
AstNode node,
919-
ConstructorElementMixin constructor,
914+
ConstructorElementMixin2 constructor,
920915
ArgumentList argumentList,
921916
) {
922917
var constantVisitor = ConstantVisitor(

0 commit comments

Comments
 (0)