Skip to content

Commit 56e3164

Browse files
scheglovCommit Queue
authored andcommitted
Element. Migrate src/dart/element/type.dart
Change-Id: I20d9dafd085941abb33f7610c392848b2a7fb553 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415683 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 3fb52b7 commit 56e3164

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
550550
final Map<String, DartObjectImpl>? _lexicalEnvironment;
551551

552552
/// A mapping of type parameter names to runtime values (types).
553-
final Map<TypeParameterElement, TypeImpl>? _lexicalTypeEnvironment;
553+
final Map<TypeParameterElement2, TypeImpl>? _lexicalTypeEnvironment;
554554

555555
final Substitution? _substitution;
556556

@@ -573,7 +573,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
573573
this._library,
574574
this._errorReporter, {
575575
Map<String, DartObjectImpl>? lexicalEnvironment,
576-
Map<TypeParameterElement, TypeImpl>? lexicalTypeEnvironment,
576+
Map<TypeParameterElement2, TypeImpl>? lexicalTypeEnvironment,
577577
Substitution? substitution,
578578
}) : _lexicalEnvironment = lexicalEnvironment,
579579
_lexicalTypeEnvironment = lexicalTypeEnvironment,
@@ -888,7 +888,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
888888
if (typeArgumentTypes != null) {
889889
var instantiatedTypeArgumentTypes = typeArgumentTypes.map((type) {
890890
if (type is TypeParameterType) {
891-
return _lexicalTypeEnvironment?[type.element] ?? type;
891+
return _lexicalTypeEnvironment?[type.element3] ?? type;
892892
} else {
893893
return type;
894894
}
@@ -1924,7 +1924,7 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
19241924
// Constants may refer to type parameters only if the constructor-tearoffs
19251925
// feature is enabled.
19261926
if (_library.featureSet.isEnabled(Feature.constructor_tearoffs)) {
1927-
var typeArgument = _lexicalTypeEnvironment?[variableElement];
1927+
var typeArgument = _lexicalTypeEnvironment?[variableElement.asElement2];
19281928
if (typeArgument != null) {
19291929
return DartObjectImpl(
19301930
typeSystem,
@@ -2634,7 +2634,7 @@ class _InstanceCreationEvaluator {
26342634

26352635
final List<DartObjectImpl> _argumentValues;
26362636

2637-
final Map<TypeParameterElement, TypeImpl> _typeParameterMap = HashMap();
2637+
final Map<TypeParameterElement2, TypeImpl> _typeParameterMap = HashMap();
26382638

26392639
final Map<String, DartObjectImpl> _parameterMap = HashMap();
26402640

@@ -3255,7 +3255,7 @@ class _InstanceCreationEvaluator {
32553255
for (int i = 0; i < typeParameters.length; i++) {
32563256
var typeParameter = typeParameters[i];
32573257
var typeArgument = typeArguments[i];
3258-
_typeParameterMap[typeParameter] = typeArgument;
3258+
_typeParameterMap[typeParameter.asElement2] = typeArgument;
32593259
}
32603260
}
32613261
}

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11117,6 +11117,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl
1111711117
if (aliasedType_ is! InterfaceTypeImpl) {
1111811118
return false;
1111911119
}
11120+
var typeParameters = element.typeParameters2;
1112011121
var aliasedClass = aliasedType_.element;
1112111122
var typeArguments = aliasedType_.typeArguments;
1112211123
var typeParameterCount = typeParameters.length;
@@ -11133,7 +11134,7 @@ class TypeAliasElementImpl extends _ExistingElementImpl
1113311134
}
1113411135
var typeArgument = typeArguments[i];
1113511136
if (typeArgument is TypeParameterType &&
11136-
typeParameters[i] != typeArgument.element) {
11137+
typeParameters[i] != typeArgument.element3) {
1113711138
return false;
1113811139
}
1113911140
}

pkg/analyzer/lib/src/dart/element/type.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
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-
75
import 'package:_fe_analyzer_shared/src/types/shared_type.dart';
86
import 'package:analyzer/dart/ast/token.dart';
97
import 'package:analyzer/dart/element/element.dart';
@@ -42,6 +40,7 @@ class DynamicTypeImpl extends TypeImpl
4240
/// Prevent the creation of instances of this class.
4341
DynamicTypeImpl._();
4442

43+
@Deprecated('Use element2 instead')
4544
@override
4645
DynamicElementImpl get element => DynamicElementImpl.instance;
4746

@@ -195,6 +194,7 @@ class FunctionTypeImpl extends TypeImpl
195194
super.alias,
196195
});
197196

197+
@Deprecated('Use element2 instead')
198198
@override
199199
Null get element => null;
200200

@@ -1193,6 +1193,7 @@ class InvalidTypeImpl extends TypeImpl
11931193
/// Prevent the creation of instances of this class.
11941194
InvalidTypeImpl._();
11951195

1196+
@Deprecated('Use element2 instead')
11961197
@override
11971198
Null get element => null;
11981199

@@ -1374,6 +1375,7 @@ class RecordTypeImpl extends TypeImpl implements RecordType, SharedRecordType {
13741375
);
13751376
}
13761377

1378+
@Deprecated('Use element2 instead')
13771379
@override
13781380
Null get element => null;
13791381

@@ -1533,6 +1535,7 @@ abstract class TypeImpl implements DartType, SharedType {
15331535
/// Initialize a newly created type.
15341536
const TypeImpl({this.alias});
15351537

1538+
@Deprecated('Use element3 instead')
15361539
@override
15371540
Element? get element => element3?.asElement;
15381541

@@ -1607,6 +1610,7 @@ abstract class TypeImpl implements DartType, SharedType {
16071610
/// Append a textual representation of this type to the given [builder].
16081611
void appendTo(ElementDisplayStringBuilder builder);
16091612

1613+
@Deprecated('Use asInstanceOf2() instead')
16101614
@override
16111615
InterfaceTypeImpl? asInstanceOf(InterfaceElement targetElement) => null;
16121616

@@ -1780,6 +1784,7 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
17801784
builder.writeTypeParameterType(this);
17811785
}
17821786

1787+
@Deprecated('Use asInstanceOf2() instead')
17831788
@override
17841789
InterfaceTypeImpl? asInstanceOf(InterfaceElement targetElement) {
17851790
return bound.asInstanceOf(targetElement);
@@ -1820,6 +1825,7 @@ class VoidTypeImpl extends TypeImpl implements VoidType, SharedVoidType {
18201825
/// Prevent the creation of instances of this class.
18211826
VoidTypeImpl._();
18221827

1828+
@Deprecated('Use element2 instead')
18231829
@override
18241830
Null get element => null;
18251831

pkg/analyzer/lib/src/dart/resolver/resolution_visitor.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,11 +1701,11 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
17011701
return;
17021702
}
17031703

1704-
var element = type.element;
1704+
var element = type.element3;
17051705
switch (element) {
1706-
case ClassElement():
1706+
case ClassElement2():
17071707
return;
1708-
case MixinElement():
1708+
case MixinElement2():
17091709
if (clause is ImplementsClause ||
17101710
clause is MixinOnClause ||
17111711
clause is WithClause) {

0 commit comments

Comments
 (0)