Files
sdk/runtime/lib/map_patch.dart
T
regis@google.com 1de3a5c0f7 Enforce rule in vm that factory name must match enclosing class name.
This is a step towards removing support for obsolete default factory classes.
For now, disable tests using obsolete syntax. More will get disabled as support
is completely removed. We may then permanently remove some tests, while updating
and reenabling others whose purpose is not related to default factory classes.
Review URL: https://codereview.chromium.org//11419191

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@15428 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-28 01:11:29 +00:00

20 lines
751 B
Dart

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
patch class Map<K, V> {
// Factory constructing a Map from a parser generated Map literal.
// [elements] contains n key-value pairs.
// The keys are at position 2*n and are already type checked by the parser
// in checked mode.
// The values are at position 2*n+1 and are not yet type checked.
factory Map._fromLiteral(List elements) {
var map = new LinkedHashMap<String, V>();
var len = elements.length;
for (int i = 1; i < len; i += 2) {
map[elements[i - 1]] = elements[i];
}
return map;
}
}