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- // ignore_for_file: analyzer_use_new_elements
6-
7- import 'package:analyzer/dart/element/element.dart' ;
5+ import 'package:analyzer/dart/element/element2.dart' ;
86import 'package:analyzer/dart/element/type.dart' ;
97import 'package:analyzer/src/dart/ast/ast.dart' ;
108import 'package:analyzer/src/dart/element/member.dart' ;
@@ -30,10 +28,10 @@ class ConstructorReferenceResolver {
3028 );
3129 }
3230 node.constructorName.accept (_resolver);
33- var element = node.constructorName.staticElement ;
31+ var element = node.constructorName.element ;
3432 if (element != null && ! element.isFactory) {
35- var enclosingElement = element.enclosingElement3 ;
36- if (enclosingElement is ClassElement && enclosingElement.isAbstract) {
33+ var enclosingElement = element.enclosingElement2 ;
34+ if (enclosingElement is ClassElement2 && enclosingElement.isAbstract) {
3735 _resolver.errorReporter.atNode (
3836 node,
3937 CompileTimeErrorCode
@@ -52,19 +50,19 @@ class ConstructorReferenceResolver {
5250 //
5351 // Only report errors when the constructor tearoff feature is enabled,
5452 // to avoid reporting redundant errors.
55- var enclosingElement = node.constructorName.type.element ;
56- if (enclosingElement is TypeAliasElement ) {
53+ var enclosingElement = node.constructorName.type.element2 ;
54+ if (enclosingElement is TypeAliasElement2 ) {
5755 var aliasedType = enclosingElement.aliasedType;
5856 enclosingElement =
59- aliasedType is InterfaceType ? aliasedType.element : null ;
57+ aliasedType is InterfaceType ? aliasedType.element3 : null ;
6058 }
6159 // TODO(srawlins): Handle `enclosingElement` being a function typedef:
6260 // typedef F<T> = void Function(); var a = F<int>.extensionOnType;`.
6361 // This is illegal.
64- if (enclosingElement is InterfaceElement ) {
65- var method = enclosingElement.getMethod (name.name) ??
66- enclosingElement.getGetter (name.name) ??
67- enclosingElement.getSetter (name.name);
62+ if (enclosingElement is InterfaceElement2 ) {
63+ var method = enclosingElement.getMethod2 (name.name) ??
64+ enclosingElement.getGetter2 (name.name) ??
65+ enclosingElement.getSetter2 (name.name);
6866 if (method != null ) {
6967 var error = method.isStatic
7068 ? CompileTimeErrorCode .CLASS_INSTANTIATION_ACCESS_TO_STATIC_MEMBER
@@ -79,7 +77,7 @@ class ConstructorReferenceResolver {
7977 _resolver.errorReporter.atNode (
8078 node,
8179 CompileTimeErrorCode .CLASS_INSTANTIATION_ACCESS_TO_UNKNOWN_MEMBER ,
82- arguments: [enclosingElement.name , name.name],
80+ arguments: [enclosingElement.name3 ! , name.name],
8381 );
8482 }
8583 }
@@ -102,7 +100,7 @@ class ConstructorReferenceResolver {
102100 // Otherwise we'll have a ConstructorElement, and we can skip inference
103101 // because there's nothing to infer in a non-generic type.
104102 if (elementToInfer != null &&
105- elementToInfer.typeParameters .isNotEmpty &&
103+ elementToInfer.typeParameters2 .isNotEmpty &&
106104 constructorName.type.typeArguments == null ) {
107105 // TODO(leafp): Currently, we may re-infer types here, since we
108106 // sometimes resolve multiple times. We should really check that we
@@ -114,7 +112,7 @@ class ConstructorReferenceResolver {
114112 // Get back to the uninstantiated generic constructor.
115113 // TODO(jmesserly): should we store this earlier in resolution?
116114 // Or look it up, instead of jumping backwards through the Member?
117- var rawElement = elementToInfer.element ;
115+ var rawElement = elementToInfer.element2 ;
118116 var constructorType = elementToInfer.asType;
119117
120118 var inferred = _resolver.inferenceHelper.inferTearOff (
@@ -127,16 +125,16 @@ class ConstructorReferenceResolver {
127125 // Update the static element as well. This is used in some cases, such
128126 // as computing constant values. It is stored in two places.
129127 var constructorElement =
130- ConstructorMember .from (rawElement, inferredReturnType);
128+ ConstructorMember .from2 (rawElement, inferredReturnType);
131129
132- constructorName.staticElement = constructorElement.declaration ;
133- constructorName.name? .staticElement = constructorElement.declaration ;
130+ constructorName.element = constructorElement.baseElement ;
131+ constructorName.name? .element = constructorElement.baseElement ;
134132 node.recordStaticType (inferred, resolver: _resolver);
135133 // The NamedType child of `constructorName` doesn't have a static type.
136134 constructorName.type.type = null ;
137135 }
138136 } else {
139- var constructorElement = constructorName.staticElement ;
137+ var constructorElement = constructorName.element ;
140138 node.recordStaticType (
141139 constructorElement == null
142140 ? InvalidTypeImpl .instance
0 commit comments