Skip to content

Commit 28d25e4

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Remove 'variable' and 'toFunctionValue' from DartObjectImpl.
Change-Id: Ia696347266cb4b54f5248fb1f9f0f73290fddc5a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437380 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 0e12390 commit 28d25e4

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ class ConstantEvaluationEngine {
156156
}
157157

158158
// Associate with the variable.
159-
dartConstant = DartObjectImpl.forVariable(dartConstant, constant);
159+
dartConstant = DartObjectImpl.forVariable(
160+
dartConstant,
161+
constant.element,
162+
);
160163
}
161164

162165
var enumConstant = _enumConstant(constant);
@@ -2173,8 +2176,8 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
21732176
FunctionReferenceImpl node,
21742177
DartObjectImpl value,
21752178
) {
2176-
var functionElement = value.toFunctionValue();
2177-
if (functionElement is! ExecutableElementOrMember) {
2179+
var functionElement = value.toFunctionValue2();
2180+
if (functionElement is! ExecutableElement2OrMember) {
21782181
return value;
21792182
}
21802183
var valueType = functionElement.type;
@@ -2208,8 +2211,8 @@ class ConstantVisitor extends UnifyingAstVisitor<Constant> {
22082211
) {
22092212
// TODO(srawlins): When all code uses [FunctionReference]s generated via
22102213
// generic function instantiation, remove this method and all call sites.
2211-
var functionElement = value.toFunctionValue();
2212-
if (functionElement is! ExecutableElementOrMember) {
2214+
var functionElement = value.toFunctionValue2();
2215+
if (functionElement is! ExecutableElement2OrMember) {
22132216
return value;
22142217
}
22152218
var valueType = functionElement.type;

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

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import 'package:analyzer/src/dart/element/extensions.dart';
2424
import 'package:analyzer/src/dart/element/type.dart';
2525
import 'package:analyzer/src/dart/element/type_system.dart';
2626
import 'package:analyzer/src/error/codes.dart';
27-
import 'package:analyzer/src/utilities/extensions/element.dart';
2827
import 'package:meta/meta.dart';
2928

3029
/// The state of an object representing a boolean value.
@@ -183,24 +182,24 @@ class DartObjectImpl implements DartObject, Constant {
183182
/// The state of the object.
184183
final InstanceState state;
185184

186-
/// If this object is the value of a constant variable, the variable.
187-
final VariableFragmentImpl? variable;
185+
@override
186+
final VariableElementImpl? variable2;
188187

189188
/// Initialize a newly created object to have the given [type] and [state].
190189
factory DartObjectImpl(
191190
TypeSystemImpl typeSystem,
192191
TypeImpl type,
193192
InstanceState state, {
194-
VariableFragmentImpl? variable,
193+
VariableElementImpl? variable,
195194
}) {
196195
type = type.extensionTypeErasure;
197-
return DartObjectImpl._(typeSystem, type, state, variable: variable);
196+
return DartObjectImpl._(typeSystem, type, state, variable2: variable);
198197
}
199198

200199
/// Creates a duplicate instance of [other], tied to [variable].
201200
factory DartObjectImpl.forVariable(
202201
DartObjectImpl other,
203-
VariableFragmentImpl variable,
202+
VariableElementImpl variable,
204203
) {
205204
return DartObjectImpl(
206205
other._typeSystem,
@@ -249,7 +248,7 @@ class DartObjectImpl implements DartObject, Constant {
249248
}
250249

251250
/// Initialize a newly created object to have the given [type] and [state].
252-
DartObjectImpl._(this._typeSystem, this.type, this.state, {this.variable}) {
251+
DartObjectImpl._(this._typeSystem, this.type, this.state, {this.variable2}) {
253252
if (state case GenericState state) {
254253
state._object = this;
255254
}
@@ -290,9 +289,6 @@ class DartObjectImpl implements DartObject, Constant {
290289
@visibleForTesting
291290
List<DartType>? get typeArguments => (state as FunctionState).typeArguments;
292291

293-
@override
294-
VariableElement? get variable2 => variable.asElement2 as VariableElement?;
295-
296292
@override
297293
bool operator ==(Object other) {
298294
if (other is DartObjectImpl) {
@@ -951,16 +947,6 @@ class DartObjectImpl implements DartObject, Constant {
951947
return null;
952948
}
953949

954-
/// Return an element corresponding to the value of the object being
955-
/// represented, or `null`
956-
/// if
957-
/// * this object is not of a function type,
958-
/// * the value of the object being represented is not known, or
959-
/// * the value of the object being represented is `null`.
960-
ExecutableElementOrMember? toFunctionValue() {
961-
return toFunctionValue2()?.asElement;
962-
}
963-
964950
@override
965951
ExecutableElement2OrMember? toFunctionValue2() {
966952
var state = this.state;

0 commit comments

Comments
 (0)