Skip to content

Commit d430e7a

Browse files
fishythefishCommit Queue
authored andcommitted
[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>
1 parent 4f5dc56 commit d430e7a

File tree

7 files changed

+42
-88
lines changed

7 files changed

+42
-88
lines changed

pkg/compiler/lib/src/js_model/closure.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,15 +1260,6 @@ class ClosureFunctionData extends ClosureMemberData
12601260
sink.end(tag);
12611261
}
12621262

1263-
@override
1264-
late final ir.Member memberContext = (() {
1265-
ir.TreeNode parent = functionNode;
1266-
while (parent is! ir.Member) {
1267-
parent = parent.parent!;
1268-
}
1269-
return parent;
1270-
})();
1271-
12721263
@override
12731264
FunctionType getFunctionType(IrToElementMap elementMap) {
12741265
return functionType;

pkg/compiler/lib/src/js_model/element_map.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ abstract class JsToElementMap {
9494
ir.StaticInvocation node);
9595

9696
/// Computes the [ConstantValue] for the constant [expression].
97-
// TODO(johnniwinther,sigmund): Remove the need for [memberContext]. This is
98-
// only needed because effectively constant expressions are not replaced by
99-
// constant expressions during resolution.
100-
ConstantValue? getConstantValue(
101-
ir.Member? memberContext, ir.Expression? expression,
97+
ConstantValue? getConstantValue(ir.Expression? expression,
10298
{bool requireConstant = true, bool implicitNull = false});
10399

104100
/// Returns the [ConstantValue] for the sentinel used to indicate that a

pkg/compiler/lib/src/js_model/element_map_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ class JsKernelToElementMap implements JsToElementMap, IrToElementMap {
13061306
}
13071307

13081308
@override
1309-
ConstantValue? getConstantValue(ir.Member? memberContext, ir.Expression? node,
1309+
ConstantValue? getConstantValue(ir.Expression? node,
13101310
{bool requireConstant = true, bool implicitNull = false}) {
13111311
if (node == null) {
13121312
if (!implicitNull) {

pkg/compiler/lib/src/js_model/env.dart

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,6 @@ mixin FunctionDataTypeVariablesMixin implements FunctionData {
685685
mixin FunctionDataForEachParameterMixin implements FunctionData {
686686
ir.FunctionNode get functionNode;
687687

688-
// TODO(johnniwinther,sigmund): Remove this when it's no longer needed for
689-
// `getConstantValue` in [forEachParameter].
690-
ir.Member get memberContext;
691-
692688
@override
693689
void forEachParameter(
694690
JsToElementMap elementMap,
@@ -708,8 +704,7 @@ mixin FunctionDataForEachParameterMixin implements FunctionData {
708704
}
709705
} else if (isOptional) {
710706
if (parameter.initializer != null) {
711-
defaultValue = elementMap.getConstantValue(
712-
memberContext, parameter.initializer!);
707+
defaultValue = elementMap.getConstantValue(parameter.initializer!);
713708
} else {
714709
defaultValue = NullConstantValue();
715710
}
@@ -772,9 +767,6 @@ class FunctionDataImpl extends JMemberDataImpl
772767
sink.end(tag);
773768
}
774769

775-
@override
776-
ir.Member get memberContext => node;
777-
778770
@override
779771
FunctionType getFunctionType(covariant JsKernelToElementMap elementMap) {
780772
return _type ??= elementMap.getFunctionType(functionNode);

pkg/compiler/lib/src/kernel/env.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ class KFunctionData extends KMemberData {
492492
ConstantValue? defaultValue;
493493
if (isOptional) {
494494
if (parameter.initializer != null) {
495-
defaultValue =
496-
elementMap.getConstantValue(node, parameter.initializer);
495+
defaultValue = elementMap.getConstantValue(parameter.initializer);
497496
} else {
498497
defaultValue = NullConstantValue();
499498
}

0 commit comments

Comments
 (0)