Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: pkg/compiler/lib/src/constants/expressions.dart

Issue 2120943002: Fix evaluation of constant map with duplicate keys. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/constants/expressions.dart
diff --git a/pkg/compiler/lib/src/constants/expressions.dart b/pkg/compiler/lib/src/constants/expressions.dart
index 922ae068073ade58b01a79f842cda00232558377..a6317d5f9830ec8b4f83ca003228f7b309cf15c4 100644
--- a/pkg/compiler/lib/src/constants/expressions.dart
+++ b/pkg/compiler/lib/src/constants/expressions.dart
@@ -482,11 +482,20 @@ class MapConstantExpression extends ConstantExpression {
@override
ConstantValue evaluate(
Environment environment, ConstantSystem constantSystem) {
+ Map<ConstantValue, ConstantValue> valueMap =
+ <ConstantValue, ConstantValue>{};
+ for (int index = 0; index < keys.length; index++) {
+ ConstantValue key =
+ keys[index].evaluate(environment, constantSystem);
+ ConstantValue value =
+ values[index].evaluate(environment, constantSystem);
+ valueMap[key] = value;
+ }
return constantSystem.createMap(
environment.compiler,
type,
- keys.map((k) => k.evaluate(environment, constantSystem)).toList(),
- values.map((v) => v.evaluate(environment, constantSystem)).toList());
+ valueMap.keys.toList(),
+ valueMap.values.toList());
}
ConstantExpression apply(NormalizedArguments arguments) {
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698