1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 20:16:39 +00:00

[dart2js] Remove memberContext from getConstantValue.

Change-Id: I3ed4343c7cd2880414a8e99361d8017ca9f756a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372160
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
This commit is contained in:
Mayank Patke 2024-06-18 18:31:58 +00:00 committed by Commit Queue
parent 4f5dc5603f
commit d430e7ab55
7 changed files with 42 additions and 88 deletions

View File

@ -1260,15 +1260,6 @@ class ClosureFunctionData extends ClosureMemberData
sink.end(tag); sink.end(tag);
} }
@override
late final ir.Member memberContext = (() {
ir.TreeNode parent = functionNode;
while (parent is! ir.Member) {
parent = parent.parent!;
}
return parent;
})();
@override @override
FunctionType getFunctionType(IrToElementMap elementMap) { FunctionType getFunctionType(IrToElementMap elementMap) {
return functionType; return functionType;

View File

@ -94,11 +94,7 @@ abstract class JsToElementMap {
ir.StaticInvocation node); ir.StaticInvocation node);
/// Computes the [ConstantValue] for the constant [expression]. /// Computes the [ConstantValue] for the constant [expression].
// TODO(johnniwinther,sigmund): Remove the need for [memberContext]. This is ConstantValue? getConstantValue(ir.Expression? expression,
// only needed because effectively constant expressions are not replaced by
// constant expressions during resolution.
ConstantValue? getConstantValue(
ir.Member? memberContext, ir.Expression? expression,
{bool requireConstant = true, bool implicitNull = false}); {bool requireConstant = true, bool implicitNull = false});
/// Returns the [ConstantValue] for the sentinel used to indicate that a /// Returns the [ConstantValue] for the sentinel used to indicate that a

View File

@ -1306,7 +1306,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
} }
@override @override
ConstantValue? getConstantValue(ir.Member? memberContext, ir.Expression? node, ConstantValue? getConstantValue(ir.Expression? node,
{bool requireConstant = true, bool implicitNull = false}) { {bool requireConstant = true, bool implicitNull = false}) {
if (node == null) { if (node == null) {
if (!implicitNull) { if (!implicitNull) {

View File

@ -685,10 +685,6 @@ mixin FunctionDataTypeVariablesMixin implements FunctionData {
mixin FunctionDataForEachParameterMixin implements FunctionData { mixin FunctionDataForEachParameterMixin implements FunctionData {
ir.FunctionNode get functionNode; ir.FunctionNode get functionNode;
// TODO(johnniwinther,sigmund): Remove this when it's no longer needed for
// `getConstantValue` in [forEachParameter].
ir.Member get memberContext;
@override @override
void forEachParameter( void forEachParameter(
JsToElementMap elementMap, JsToElementMap elementMap,
@ -708,8 +704,7 @@ mixin FunctionDataForEachParameterMixin implements FunctionData {
} }
} else if (isOptional) { } else if (isOptional) {
if (parameter.initializer != null) { if (parameter.initializer != null) {
defaultValue = elementMap.getConstantValue( defaultValue = elementMap.getConstantValue(parameter.initializer!);
memberContext, parameter.initializer!);
} else { } else {
defaultValue = NullConstantValue(); defaultValue = NullConstantValue();
} }
@ -772,9 +767,6 @@ class FunctionDataImpl extends JMemberDataImpl
sink.end(tag); sink.end(tag);
} }
@override
ir.Member get memberContext => node;
@override @override
FunctionType getFunctionType(covariant JsKernelToElementMap elementMap) { FunctionType getFunctionType(covariant JsKernelToElementMap elementMap) {
return _type ??= elementMap.getFunctionType(functionNode); return _type ??= elementMap.getFunctionType(functionNode);

View File

@ -492,8 +492,7 @@ class KFunctionData extends KMemberData {
ConstantValue? defaultValue; ConstantValue? defaultValue;
if (isOptional) { if (isOptional) {
if (parameter.initializer != null) { if (parameter.initializer != null) {
defaultValue = defaultValue = elementMap.getConstantValue(parameter.initializer);
elementMap.getConstantValue(node, parameter.initializer);
} else { } else {
defaultValue = NullConstantValue(); defaultValue = NullConstantValue();
} }

View File

@ -163,8 +163,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
final FunctionInlineCache _inlineCache; final FunctionInlineCache _inlineCache;
final InlineDataCache _inlineDataCache; final InlineDataCache _inlineDataCache;
final ir.Member? _memberContextNode;
KernelSsaGraphBuilder( KernelSsaGraphBuilder(
this.options, this.options,
this.reporter, this.reporter,
@ -184,9 +182,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
this._inlineDataCache) this._inlineDataCache)
: this.targetElement = _effectiveTargetElementFor(_initialTargetElement), : this.targetElement = _effectiveTargetElementFor(_initialTargetElement),
this._closureDataLookup = closedWorld.closureDataLookup, this._closureDataLookup = closedWorld.closureDataLookup,
this._recordData = closedWorld.recordData, this._recordData = closedWorld.recordData {
_memberContextNode =
_elementMap.getMemberContextNode(_initialTargetElement) {
_enterFrame(targetElement, null); _enterFrame(targetElement, null);
_loopHandler = KernelLoopHandler(this); _loopHandler = KernelLoopHandler(this);
_typeBuilder = KernelTypeBuilder(this, _elementMap); _typeBuilder = KernelTypeBuilder(this, _elementMap);
@ -438,10 +434,10 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
if (target is ir.Procedure) { if (target is ir.Procedure) {
if (target.isExternal) { if (target.isExternal) {
_buildExternalFunctionNode(targetElement as FunctionEntity, _buildExternalFunctionNode(targetElement as FunctionEntity,
_ensureDefaultArgumentValues(target, target.function)); _ensureDefaultArgumentValues(target.function));
} else { } else {
_buildFunctionNode(targetElement as FunctionEntity, _buildFunctionNode(targetElement as FunctionEntity,
_ensureDefaultArgumentValues(target, target.function)); _ensureDefaultArgumentValues(target.function));
} }
} else if (target is ir.Field) { } else if (target is ir.Field) {
FieldAnalysisData fieldData = closedWorld.fieldAnalysis FieldAnalysisData fieldData = closedWorld.fieldAnalysis
@ -481,7 +477,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
} }
} else if (target is ir.LocalFunction) { } else if (target is ir.LocalFunction) {
_buildFunctionNode(targetElement as FunctionEntity, _buildFunctionNode(targetElement as FunctionEntity,
_ensureDefaultArgumentValues(null, target.function)); _ensureDefaultArgumentValues(target.function));
} else { } else {
throw 'No case implemented to handle target: ' throw 'No case implemented to handle target: '
'$target for $targetElement'; '$target for $targetElement';
@ -489,12 +485,12 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
break; break;
case MemberKind.constructor: case MemberKind.constructor:
final constructor = definition.node as ir.Constructor; final constructor = definition.node as ir.Constructor;
_ensureDefaultArgumentValues(constructor, constructor.function); _ensureDefaultArgumentValues(constructor.function);
_buildConstructor(targetElement as ConstructorEntity, constructor); _buildConstructor(targetElement as ConstructorEntity, constructor);
break; break;
case MemberKind.constructorBody: case MemberKind.constructorBody:
final constructor = definition.node as ir.Constructor; final constructor = definition.node as ir.Constructor;
_ensureDefaultArgumentValues(constructor, constructor.function); _ensureDefaultArgumentValues(constructor.function);
_buildConstructorBody(constructor); _buildConstructorBody(constructor);
break; break;
case MemberKind.closureField: case MemberKind.closureField:
@ -554,8 +550,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
return null; return null;
} }
ir.FunctionNode _ensureDefaultArgumentValues( ir.FunctionNode _ensureDefaultArgumentValues(ir.FunctionNode function) {
ir.Member? member, ir.FunctionNode function) {
// Register all [function]'s default argument values. // Register all [function]'s default argument values.
// //
// Default values might be (or contain) functions that are not referenced // Default values might be (or contain) functions that are not referenced
@ -570,8 +565,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
// there are only very small number of constants created here that are not // there are only very small number of constants created here that are not
// actually used. // actually used.
void _registerDefaultValue(ir.VariableDeclaration node) { void _registerDefaultValue(ir.VariableDeclaration node) {
final constantValue = _elementMap final constantValue =
.getConstantValue(member, node.initializer, implicitNull: true); _elementMap.getConstantValue(node.initializer, implicitNull: true);
assert( assert(
constantValue != null, constantValue != null,
failedAt(_elementMap.getMethod(function.parent as ir.Procedure), failedAt(_elementMap.getMethod(function.parent as ir.Procedure),
@ -1086,7 +1081,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
} }
List<HInstruction> _normalizeAndBuildArguments( List<HInstruction> _normalizeAndBuildArguments(
ir.Member member, ir.FunctionNode function, ir.Arguments arguments) { ir.FunctionNode function, ir.Arguments arguments) {
List<HInstruction> builtArguments = []; List<HInstruction> builtArguments = [];
var positionalIndex = 0; var positionalIndex = 0;
function.positionalParameters.forEach((ir.VariableDeclaration parameter) { function.positionalParameters.forEach((ir.VariableDeclaration parameter) {
@ -1094,7 +1089,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
arguments.positional[positionalIndex++].accept(this); arguments.positional[positionalIndex++].accept(this);
builtArguments.add(pop()); builtArguments.add(pop());
} else { } else {
builtArguments.add(_defaultValueForParameter(member, parameter)); builtArguments.add(_defaultValueForParameter(parameter));
} }
}); });
// Evaluate named arguments in given order. // Evaluate named arguments in given order.
@ -1104,7 +1099,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
..sort(namedOrdering) ..sort(namedOrdering)
..forEach((ir.VariableDeclaration parameter) { ..forEach((ir.VariableDeclaration parameter) {
var argument = namedArguments[parameter.name]; var argument = namedArguments[parameter.name];
argument ??= _defaultValueForParameter(member, parameter); argument ??= _defaultValueForParameter(parameter);
builtArguments.add(argument); builtArguments.add(argument);
}); });
@ -1118,9 +1113,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
ConstructorData constructorData, ir.Constructor caller) { ConstructorData constructorData, ir.Constructor caller) {
ir.Constructor superOrRedirectConstructor = initializer.target; ir.Constructor superOrRedirectConstructor = initializer.target;
List<HInstruction> arguments = _normalizeAndBuildArguments( List<HInstruction> arguments = _normalizeAndBuildArguments(
superOrRedirectConstructor, superOrRedirectConstructor.function, initializer.arguments);
superOrRedirectConstructor.function,
initializer.arguments);
// Redirecting initializer already has [localsHandler] bindings for type // Redirecting initializer already has [localsHandler] bindings for type
// parameters from the redirecting constructor. // parameters from the redirecting constructor.
@ -1138,8 +1131,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
void _inlineSuperInitializer(ir.SuperInitializer initializer, void _inlineSuperInitializer(ir.SuperInitializer initializer,
ConstructorData constructorData, ir.Constructor caller) { ConstructorData constructorData, ir.Constructor caller) {
ir.Constructor target = initializer.target; ir.Constructor target = initializer.target;
List<HInstruction> arguments = _normalizeAndBuildArguments( List<HInstruction> arguments =
target, target.function, initializer.arguments); _normalizeAndBuildArguments(target.function, initializer.arguments);
ir.Class callerClass = caller.enclosingClass; ir.Class callerClass = caller.enclosingClass;
ir.Supertype supertype = callerClass.supertype!; ir.Supertype supertype = callerClass.supertype!;
@ -1998,8 +1991,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
if (memberContextNode != null) { if (memberContextNode != null) {
for (ir.VariableDeclaration node in elidedParameters) { for (ir.VariableDeclaration node in elidedParameters) {
Local local = _localsMap.getLocalVariable(node); Local local = _localsMap.getLocalVariable(node);
localsHandler.updateLocal( localsHandler.updateLocal(local, _defaultValueForParameter(node));
local, _defaultValueForParameter(memberContextNode, node));
} }
} }
@ -2147,8 +2139,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
@override @override
void visitConstantExpression(ir.ConstantExpression node) { void visitConstantExpression(ir.ConstantExpression node) {
ConstantValue value = ConstantValue value = _elementMap.getConstantValue(node)!;
_elementMap.getConstantValue(_memberContextNode!, node)!;
final sourceInformation = _sourceInformationBuilder.buildGet(node); final sourceInformation = _sourceInformationBuilder.buildGet(node);
if (!closedWorld.outputUnitData if (!closedWorld.outputUnitData
.hasOnlyNonDeferredImportPathsToConstant(targetElement, value)) { .hasOnlyNonDeferredImportPathsToConstant(targetElement, value)) {
@ -3043,8 +3034,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
Map<ir.Expression, ConstantValue> constants = {}; Map<ir.Expression, ConstantValue> constants = {};
for (ir.SwitchCase switchCase in switchStatement.cases) { for (ir.SwitchCase switchCase in switchStatement.cases) {
for (ir.Expression caseExpression in switchCase.expressions) { for (ir.Expression caseExpression in switchCase.expressions) {
final constant = final constant = _elementMap.getConstantValue(caseExpression)!;
_elementMap.getConstantValue(_memberContextNode!, caseExpression)!;
constants[caseExpression] = constant; constants[caseExpression] = constant;
} }
} }
@ -3482,8 +3472,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
@override @override
void visitSymbolLiteral(ir.SymbolLiteral node) { void visitSymbolLiteral(ir.SymbolLiteral node) {
stack.add(graph.addConstant( stack.add(
_elementMap.getConstantValue(_memberContextNode!, node)!, closedWorld)); graph.addConstant(_elementMap.getConstantValue(node)!, closedWorld));
registry.registerConstSymbol(node.value); registry.registerConstSymbol(node.value);
} }
@ -3514,9 +3504,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
void visitListLiteral(ir.ListLiteral node) { void visitListLiteral(ir.ListLiteral node) {
HInstruction listInstruction; HInstruction listInstruction;
if (node.isConst) { if (node.isConst) {
listInstruction = graph.addConstant( listInstruction =
_elementMap.getConstantValue(_memberContextNode!, node)!, graph.addConstant(_elementMap.getConstantValue(node)!, closedWorld);
closedWorld);
} else { } else {
List<HInstruction> elements = []; List<HInstruction> elements = [];
for (ir.Expression element in node.expressions) { for (ir.Expression element in node.expressions) {
@ -3544,9 +3533,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
@override @override
void visitSetLiteral(ir.SetLiteral node) { void visitSetLiteral(ir.SetLiteral node) {
if (node.isConst) { if (node.isConst) {
stack.add(graph.addConstant( stack.add(
_elementMap.getConstantValue(_memberContextNode!, node)!, graph.addConstant(_elementMap.getConstantValue(node)!, closedWorld));
closedWorld));
return; return;
} }
@ -3625,9 +3613,8 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
@override @override
void visitMapLiteral(ir.MapLiteral node) { void visitMapLiteral(ir.MapLiteral node) {
if (node.isConst) { if (node.isConst) {
stack.add(graph.addConstant( stack.add(
_elementMap.getConstantValue(_memberContextNode!, node)!, graph.addConstant(_elementMap.getConstantValue(node)!, closedWorld));
closedWorld));
return; return;
} }
@ -3818,7 +3805,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
ir.DartType type = node.type; ir.DartType type = node.type;
DartType dartType = _elementMap.getDartType(type); DartType dartType = _elementMap.getDartType(type);
if (!dartType.containsTypeVariables) { if (!dartType.containsTypeVariables) {
final constant = _elementMap.getConstantValue(_memberContextNode!, node)!; final constant = _elementMap.getConstantValue(node)!;
stack.add(graph.addConstant(constant, closedWorld, stack.add(graph.addConstant(constant, closedWorld,
sourceInformation: sourceInformation)); sourceInformation: sourceInformation));
return; return;
@ -4040,8 +4027,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
HInstruction initialValue = graph.addConstantNull(closedWorld); HInstruction initialValue = graph.addConstantNull(closedWorld);
localsHandler.updateLocal(local, initialValue); localsHandler.updateLocal(local, initialValue);
} else if (node.isConst) { } else if (node.isConst) {
final constant = final constant = _elementMap.getConstantValue(node.initializer);
_elementMap.getConstantValue(_memberContextNode!, node.initializer);
assert(constant != null, failedAt(CURRENT_ELEMENT_SPANNABLE)); assert(constant != null, failedAt(CURRENT_ELEMENT_SPANNABLE));
HInstruction initialValue = graph.addConstant(constant!, closedWorld); HInstruction initialValue = graph.addConstant(constant!, closedWorld);
localsHandler.updateLocal(local, initialValue); localsHandler.updateLocal(local, initialValue);
@ -4246,7 +4232,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
/// Build argument list in canonical order for a static [target], including /// Build argument list in canonical order for a static [target], including
/// filling in the default argument value. /// filling in the default argument value.
List<HInstruction> _visitArgumentsForStaticTarget( List<HInstruction> _visitArgumentsForStaticTarget(
ir.Member memberContextNode,
ir.FunctionNode target, ir.FunctionNode target,
ParameterStructure parameterStructure, ParameterStructure parameterStructure,
ir.Arguments arguments, ir.Arguments arguments,
@ -4258,7 +4243,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
while (values.length < parameterStructure.positionalParameters) { while (values.length < parameterStructure.positionalParameters) {
ir.VariableDeclaration parameter = ir.VariableDeclaration parameter =
target.positionalParameters[values.length]; target.positionalParameters[values.length];
values.add(_defaultValueForParameter(memberContextNode, parameter)); values.add(_defaultValueForParameter(parameter));
} }
if (parameterStructure.namedParameters.isNotEmpty) { if (parameterStructure.namedParameters.isNotEmpty) {
@ -4277,7 +4262,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
for (ir.VariableDeclaration parameter in namedParameters) { for (ir.VariableDeclaration parameter in namedParameters) {
final value = namedValues[parameter.name]; final value = namedValues[parameter.name];
if (value == null) { if (value == null) {
values.add(_defaultValueForParameter(memberContextNode, parameter)); values.add(_defaultValueForParameter(parameter));
} else { } else {
values.add(value); values.add(value);
namedValues.remove(parameter.name); namedValues.remove(parameter.name);
@ -4301,11 +4286,9 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
} }
} }
HInstruction _defaultValueForParameter( HInstruction _defaultValueForParameter(ir.VariableDeclaration parameter) {
ir.Member memberContextNode, ir.VariableDeclaration parameter) { final constant =
final constant = _elementMap.getConstantValue( _elementMap.getConstantValue(parameter.initializer, implicitNull: true);
memberContextNode, parameter.initializer,
implicitNull: true);
assert(constant != null, failedAt(CURRENT_ELEMENT_SPANNABLE)); assert(constant != null, failedAt(CURRENT_ELEMENT_SPANNABLE));
return graph.addConstant(constant!, closedWorld); return graph.addConstant(constant!, closedWorld);
} }
@ -4349,8 +4332,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
if (node.isConst) { if (node.isConst) {
// Just like all const constructors (see visitConstructorInvocation). // Just like all const constructors (see visitConstructorInvocation).
stack.add(graph.addConstant( stack.add(graph.addConstant(
_elementMap.getConstantValue(_memberContextNode!, node)!, _elementMap.getConstantValue(node)!, closedWorld,
closedWorld,
sourceInformation: sourceInformation)); sourceInformation: sourceInformation));
} else { } else {
_generateUnsupportedError( _generateUnsupportedError(
@ -4375,7 +4357,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
_pushStaticNativeInvocation(function, arguments, typeMask, typeArguments); _pushStaticNativeInvocation(function, arguments, typeMask, typeArguments);
} else { } else {
final arguments = _visitArgumentsForStaticTarget( final arguments = _visitArgumentsForStaticTarget(
target,
target.function, target.function,
function.parameterStructure, function.parameterStructure,
node.arguments, node.arguments,
@ -6035,7 +6016,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
MemberDefinition targetDefinition = _elementMap.getMemberDefinition(member); MemberDefinition targetDefinition = _elementMap.getMemberDefinition(member);
final target = targetDefinition.node as ir.Procedure; final target = targetDefinition.node as ir.Procedure;
List<HInstruction> arguments = _visitArgumentsForStaticTarget( List<HInstruction> arguments = _visitArgumentsForStaticTarget(
target,
target.function, target.function,
member.parameterStructure, member.parameterStructure,
node.arguments, node.arguments,
@ -6076,8 +6056,7 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
final sourceInformation = _sourceInformationBuilder.buildNew(node); final sourceInformation = _sourceInformationBuilder.buildNew(node);
ir.Constructor target = node.target; ir.Constructor target = node.target;
if (node.isConst) { if (node.isConst) {
ConstantValue constant = ConstantValue constant = _elementMap.getConstantValue(node)!;
_elementMap.getConstantValue(_memberContextNode!, node)!;
stack.add(graph.addConstant(constant, closedWorld, stack.add(graph.addConstant(constant, closedWorld,
sourceInformation: sourceInformation)); sourceInformation: sourceInformation));
return; return;
@ -6117,7 +6096,6 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
_getConstructorTypeArguments(constructor, node.arguments); _getConstructorTypeArguments(constructor, node.arguments);
arguments.addAll(_visitArgumentsForStaticTarget( arguments.addAll(_visitArgumentsForStaticTarget(
target,
target.function, target.function,
constructor.parameterStructure, constructor.parameterStructure,
node.arguments, node.arguments,
@ -6732,14 +6710,12 @@ class KernelSsaGraphBuilder extends ir.VisitorDefault<void>
localsHandler.thisLocal!, compiledArguments[argumentIndex++]); localsHandler.thisLocal!, compiledArguments[argumentIndex++]);
} }
final memberContextNode = _elementMap.getMemberContextNode(function)!;
KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(function); KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(function);
forEachOrderedParameter(_elementMap, function, forEachOrderedParameter(_elementMap, function,
(ir.VariableDeclaration variable, {required bool isElided}) { (ir.VariableDeclaration variable, {required bool isElided}) {
Local local = localsMap.getLocalVariable(variable); Local local = localsMap.getLocalVariable(variable);
if (isElided) { if (isElided) {
localsHandler.updateLocal( localsHandler.updateLocal(local, _defaultValueForParameter(variable));
local, _defaultValueForParameter(memberContextNode, variable));
return; return;
} }
if (forGenerativeConstructorBody && if (forGenerativeConstructorBody &&

View File

@ -286,7 +286,7 @@ class OutputUnitIrComputer extends IrDataExtractor<Features> {
Features computeMemberValue(Id id, ir.Member node) { Features computeMemberValue(Id id, ir.Member node) {
if (node is ir.Field && node.isConst) { if (node is ir.Field && node.isConst) {
ir.Expression? initializer = node.initializer!; ir.Expression? initializer = node.initializer!;
ConstantValue constant = _elementMap.getConstantValue(node, initializer)!; ConstantValue constant = _elementMap.getConstantValue(initializer)!;
if (constant is! PrimitiveConstantValue) { if (constant is! PrimitiveConstantValue) {
SourceSpan span = computeSourceSpanFromTreeNode(initializer); SourceSpan span = computeSourceSpanFromTreeNode(initializer);
if (initializer is ir.ConstructorInvocation) { if (initializer is ir.ConstructorInvocation) {
@ -318,7 +318,7 @@ class OutputUnitIrComputer extends IrDataExtractor<Features> {
@override @override
visitConstantExpression(ir.ConstantExpression node) { visitConstantExpression(ir.ConstantExpression node) {
ConstantValue constant = _elementMap.getConstantValue(null, node)!; ConstantValue constant = _elementMap.getConstantValue(node)!;
if (constant is! PrimitiveConstantValue) { if (constant is! PrimitiveConstantValue) {
_constants.add('${constant.toStructuredText(_elementMap.types)}=' _constants.add('${constant.toStructuredText(_elementMap.types)}='
'${outputUnitString(_data.outputUnitForConstant(constant))}'); '${outputUnitString(_data.outputUnitForConstant(constant))}');