@@ -867,8 +867,8 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
867
867
return null ;
868
868
}
869
869
}
870
- // validate prefixed identifier
871
- return _getConstantValue (node, node.staticElement );
870
+ // Validate prefixed identifier.
871
+ return _getConstantValue (node, node.identifier );
872
872
}
873
873
874
874
@override
@@ -902,7 +902,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
902
902
return prefixResult.stringLength (typeSystem);
903
903
}
904
904
}
905
- return _getConstantValue (node, node.propertyName.staticElement );
905
+ return _getConstantValue (node, node.propertyName);
906
906
}
907
907
908
908
@override
@@ -971,7 +971,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
971
971
return _instantiateFunctionType (node, value);
972
972
}
973
973
974
- return _getConstantValue (node, node.staticElement );
974
+ return _getConstantValue (node, node);
975
975
}
976
976
977
977
@override
@@ -1171,9 +1171,11 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
1171
1171
}
1172
1172
1173
1173
/// Return the constant value of the static constant represented by the given
1174
- /// [element ] . The [node] is the node to be used if an error needs to be
1174
+ /// [identifier ] . The [node] is the node to be used if an error needs to be
1175
1175
/// reported.
1176
- DartObjectImpl ? _getConstantValue (Expression node, Element ? element) {
1176
+ DartObjectImpl ? _getConstantValue (
1177
+ Expression node, SimpleIdentifier identifier) {
1178
+ var element = identifier.staticElement;
1177
1179
element = element? .declaration;
1178
1180
var variableElement =
1179
1181
element is PropertyAccessorElement ? element.variable : element;
@@ -1196,7 +1198,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
1196
1198
if (value == null ) {
1197
1199
return value;
1198
1200
}
1199
- return _instantiateFunctionType (node , value);
1201
+ return _instantiateFunctionType (identifier , value);
1200
1202
}
1201
1203
} else if (variableElement is ConstructorElement ) {
1202
1204
return DartObjectImpl (
@@ -1207,11 +1209,12 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
1207
1209
} else if (variableElement is ExecutableElement ) {
1208
1210
var function = element as ExecutableElement ;
1209
1211
if (function.isStatic) {
1210
- return DartObjectImpl (
1212
+ var rawType = DartObjectImpl (
1211
1213
typeSystem,
1212
- node.typeOrThrow ,
1214
+ function.type ,
1213
1215
FunctionState (function),
1214
1216
);
1217
+ return _instantiateFunctionType (identifier, rawType);
1215
1218
}
1216
1219
} else if (variableElement is ClassElement ) {
1217
1220
var type = variableElement.instantiate (
@@ -1264,10 +1267,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
1264
1267
/// type-instantiated with those [node] 's tear-off type argument types,
1265
1268
/// otherwise returns [value] .
1266
1269
DartObjectImpl ? _instantiateFunctionType (
1267
- Expression node, DartObjectImpl value) {
1268
- if (node is ! SimpleIdentifier ) {
1269
- return value;
1270
- }
1270
+ SimpleIdentifier node, DartObjectImpl value) {
1271
1271
var functionElement = value.toFunctionValue ();
1272
1272
if (functionElement is ! ExecutableElement ) {
1273
1273
return value;
0 commit comments