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

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

Issue 2769613002: Add constantExpressionRequired to BodyBuilder. (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 8097c4baf12a2cd514e3f577b63d069b735bff23..e0db0d2d00c55ae1a3b1d8ed02dc8dfd01c2200b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -124,6 +124,8 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
CloneVisitor cloner;
+ bool constantExpressionRequired = false;
+
BodyBuilder(
KernelLibraryBuilder library,
this.member,
@@ -1657,12 +1659,30 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
}
@override
+ void beginNewExpression(Token token) {
+ debugEvent("beginNewExpression");
+ super.push(constantExpressionRequired);
+ if (constantExpressionRequired) {
+ addCompileTimeError(token.charOffset, "Not a constant expression.");
+ }
+ constantExpressionRequired = false;
+ }
+
+ @override
+ void beginConstExpression(Token token) {
+ debugEvent("beginConstExpression");
+ super.push(constantExpressionRequired);
+ constantExpressionRequired = true;
+ }
+
+ @override
void endNewExpression(Token token) {
debugEvent("NewExpression");
Arguments arguments = pop();
String name = pop();
List<DartType> typeArguments = pop();
var type = pop();
+ constantExpressionRequired = pop();
if (arguments == null) {
push(buildCompileTimeError("No arguments.", token.charOffset));
« 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