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

Issue 8637018: Implement type checking of map literals (issue 221). (Closed)

Created:
9 years, 1 month ago by regis
Modified:
9 years, 1 month ago
Reviewers:
srdjan, hausner, Ivan Posva
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Implement type checking of map literals (issue 221). Support proper syntax for map literals (at most one type argument is allowed) and give a warning when legacy syntax is used. Add tests. Fix tests. Committed: https://code.google.com/p/dart/source/detail?r=1764

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 8

Patch Set 4 : '' #

Patch Set 5 : '' #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+268 lines, -47 lines) Patch
M runtime/lib/error.cc View 1 2 3 4 1 chunk +17 lines, -0 lines 0 comments Download
M runtime/lib/error.dart View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M runtime/lib/immutable_map.dart View 1 2 3 4 1 chunk +0 lines, -13 lines 0 comments Download
M runtime/lib/lib_sources.gypi View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
A runtime/lib/literal_map_factory.dart View 1 2 3 1 chunk +26 lines, -0 lines 2 comments Download
M runtime/vm/bootstrap_natives.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/code_generator_ia32.cc View 1 2 3 4 1 chunk +4 lines, -2 lines 0 comments Download
M runtime/vm/parser.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/parser.cc View 1 2 3 4 8 chunks +102 lines, -23 lines 2 comments Download
M tests/language/language.status View 1 2 3 4 2 chunks +5 lines, -0 lines 0 comments Download
A tests/language/src/MapLiteral1NegativeTest.dart View 1 2 3 1 chunk +22 lines, -0 lines 0 comments Download
A tests/language/src/MapLiteral2NegativeTest.dart View 1 chunk +22 lines, -0 lines 0 comments Download
M tests/language/src/MapLiteral3Test.dart View 1 2 3 4 2 chunks +8 lines, -8 lines 0 comments Download
A tests/language/src/MapLiteral4Test.dart View 1 chunk +53 lines, -0 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
regis
I will update the various test status files before submitting, so that dartc, frog, and ...
9 years, 1 month ago (2011-11-22 17:38:32 UTC) #1
hausner
LGTM with a couple of Qs. http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_factory.dart File runtime/lib/literal_map_factory.dart (right): http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_factory.dart#newcode12 runtime/lib/literal_map_factory.dart:12: var map = ...
9 years, 1 month ago (2011-11-22 18:37:34 UTC) #2
regis
Thanks http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_factory.dart File runtime/lib/literal_map_factory.dart (right): http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_factory.dart#newcode12 runtime/lib/literal_map_factory.dart:12: var map = new LinkedHashMap<K, V>(); On 2011/11/22 ...
9 years, 1 month ago (2011-11-22 20:15:19 UTC) #3
srdjan
DBC http://codereview.chromium.org/8637018/diff/14001/runtime/lib/literal_map_factory.dart File runtime/lib/literal_map_factory.dart (right): http://codereview.chromium.org/8637018/diff/14001/runtime/lib/literal_map_factory.dart#newcode22 runtime/lib/literal_map_factory.dart:22: map[elements[i-1]] = elements[i]; space between -> 'i - ...
9 years, 1 month ago (2011-11-23 03:43:42 UTC) #4
hausner
Additional Q. http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_factory.dart File runtime/lib/literal_map_factory.dart (right): http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_factory.dart#newcode16 runtime/lib/literal_map_factory.dart:16: if (elements[i] is !V) { At the ...
9 years, 1 month ago (2011-11-23 15:40:10 UTC) #5
regis
9 years, 1 month ago (2011-11-23 15:51:32 UTC) #6
Thanks guys.
I will address this feedback in the currently pending cl fixing the list
literals.

http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_fac...
File runtime/lib/literal_map_factory.dart (right):

http://codereview.chromium.org/8637018/diff/10001/runtime/lib/literal_map_fac...
runtime/lib/literal_map_factory.dart:16: if (elements[i] is !V) {
On 2011/11/23 15:40:10, hausner wrote:
> At the cost of duplicated type checks?  Why not declare map without type
> arguments then to avoid the second (redundant) check? The user cannot add
> anything to that map later, since it is immutable, so I'm not sure how the the
> type arguments would ever be helpful.
>  
> On 2011/11/22 20:15:20, regis wrote:
> > On 2011/11/22 18:37:35, hausner wrote:
> > > Why do you have to explicitly implement the type check? Would the
assignment
> > in
> > > line 22 below not throw a type error if elements[i] isn't of type V?
> (because
> > > map is declared to be of type <K, V>)
> > 
> > Yes, we would get a type error here, but the user would not know how to deal
> > with it. So I intercept the error and report it with a more useful error
> > message.
> 

Actually, this code has changed now. See the other pending cl fixing issue 220.
This was wrong, as the test was done in non checked mode as well.

http://codereview.chromium.org/8637018/diff/14001/runtime/lib/literal_map_fac...
File runtime/lib/literal_map_factory.dart (right):

http://codereview.chromium.org/8637018/diff/14001/runtime/lib/literal_map_fac...
runtime/lib/literal_map_factory.dart:22: map[elements[i-1]] = elements[i];
On 2011/11/23 03:43:44, srdjan wrote:
> space between -> 'i - 1'

Will do.

http://codereview.chromium.org/8637018/diff/14001/runtime/vm/parser.cc
File runtime/vm/parser.cc (right):

http://codereview.chromium.org/8637018/diff/14001/runtime/vm/parser.cc#newcode29
runtime/vm/parser.cc:29: DECLARE_FLAG(bool, expose_core_impl);
On 2011/11/23 03:43:44, srdjan wrote:
> Future CL: Since we are using this flag only for de-privatizing coreimpl
> classes, maybe we could rename it to expose_private_core_impl.

Will do.

Powered by Google App Engine
This is Rietveld 408576698