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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Issue 2770243002: Allow identical as a compile-time constant. (Closed)
Patch Set: Remove one negation. Created 3 years, 9 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/co19/co19-kernel.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 4f93069d9642525c687d9e003229882c8b1c3244..99d52df96e4e934f17d9a0273722e96a9d053a75 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -517,8 +517,14 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
@override
finishSend(Object receiver, Arguments arguments, int charOffset) {
+ bool isIdentical(Object receiver) {
+ return receiver is StaticAccessor &&
+ receiver.readTarget ==
+ coreTypes.tryGetTopLevelMember("dart:core", null, "identical");
+ }
+
if (receiver is BuilderAccessor) {
- if (constantExpressionRequired) {
+ if (constantExpressionRequired && !isIdentical(receiver)) {
addCompileTimeError(charOffset, "Not a constant expression.");
}
return receiver.doInvocation(charOffset, arguments);
@@ -799,7 +805,9 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
new StaticAccessor.fromBuilder(this, builder, charOffset, setter);
if (constantExpressionRequired) {
Member readTarget = accessor.readTarget;
- if (!(readTarget is Field && readTarget.isConst)) {
+ if (!(readTarget is Field && readTarget.isConst ||
+ // Static tear-offs are also compile time constants.
+ readTarget is Procedure)) {
addCompileTimeError(charOffset, "Not a constant expression.");
}
}
« no previous file with comments | « no previous file | tests/co19/co19-kernel.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698