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

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

Issue 2770243002: Allow identical as a compile-time constant. (Closed)
Patch Set: 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 1e034529bf260b3f24d8dd24b0060cf783703d59..8f76e3ba6d991fa1e84fed42c81c54496f77a78d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -519,7 +519,12 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
finishSend(Object receiver, Arguments arguments, int charOffset) {
if (receiver is BuilderAccessor) {
if (constantExpressionRequired) {
- addCompileTimeError(charOffset, "Not a constant expression.");
+ if (!(receiver is StaticAccessor &&
karlklose 2017/03/24 08:42:30 Maybe move the checks in l. 523-525 to a helper ca
ahe 2017/03/24 13:14:35 Done.
+ receiver.readTarget ==
+ coreTypes.tryGetTopLevelMember(
+ "dart:core", null, "identical"))) {
+ addCompileTimeError(charOffset, "Not a constant expression.");
+ }
}
return receiver.doInvocation(charOffset, arguments);
} else if (receiver is UnresolvedIdentifier) {
@@ -799,7 +804,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