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

Issue 267923004: Check const map literal keys and switch case exprs using type of constant. (Closed)

Created:
6 years, 7 months ago by Paul Berry
Modified:
6 years, 7 months ago
CC:
reviews_dartlang.org, ricow1
Visibility:
Public.

Description

Check const map literal keys and switch case exprs using type of constant. The following type rules are defined based on the actual type of the const object: - CONST_MAP_KEY_EXPRESSION_TYPE_IMPLEMENTS_EQUALS - INCONSISTENT_CASE_EXPRESSION_TYPES - CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS Previously, we were using the propagated type for the case expression checks, and the static type for the const map check. BUG=dartbug.com/11697 R=brianwilkerson@google.com, scheglov@google.com Committed: https://code.google.com/p/dart/source/detail?r=35723

Patch Set 1 #

Total comments: 8

Messages

Total messages: 7 (0 generated)
Paul Berry
https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java File editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java (right): https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java#newcode269 editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java:269: // TODO(jwren) Revisit this algorithm, should there up to ...
6 years, 7 months ago (2014-05-03 13:33:06 UTC) #1
Brian Wilkerson
LGTM https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java File editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java (right): https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java#newcode269 editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java:269: // TODO(jwren) Revisit this algorithm, should there up ...
6 years, 7 months ago (2014-05-03 15:03:34 UTC) #2
scheglov
lgtm
6 years, 7 months ago (2014-05-03 16:47:43 UTC) #3
Paul Berry
Committed patchset #1 manually as r35723 (presubmit successful).
6 years, 7 months ago (2014-05-03 17:14:17 UTC) #4
Paul Berry
https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java File editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java (right): https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java#newcode269 editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java:269: // TODO(jwren) Revisit this algorithm, should there up to ...
6 years, 7 months ago (2014-05-03 17:14:56 UTC) #5
jwren
https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java File editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java (right): https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java#newcode269 editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java:269: // TODO(jwren) Revisit this algorithm, should there up to ...
6 years, 7 months ago (2014-05-03 23:03:59 UTC) #6
Brian Wilkerson
6 years, 7 months ago (2014-05-04 04:39:12 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.goo...
File
editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java
(right):

https://codereview.chromium.org/267923004/diff/1/editor/tools/plugins/com.goo...
editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ConstantVerifier.java:363:
if (type == null || type.equals(intType) ||
type.equals(typeProvider.getStringType())) {
> What about other nums such as the num type, double, etc.?

The specification explicitly states:

It is a compile-time error if the class C has an implementation of the operator
== other than the one inherited from Object unless the value of the expression
is a string or integer.

num and double are not explicitly mentioned. (And actually (a) we need to handle
double specially in next condition and (b) num is an abstract class so there
won't ever be an instance of it.)

Powered by Google App Engine
This is Rietveld 408576698