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

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

Issue 2908113002: Various constant checks. (Closed)
Patch Set: Created 3 years, 7 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 | pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart » ('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 633198a1025d6c468b9e5d079f054b3e7a298e36..258344083f6f9af9c13902181890308a3d8a739b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -1546,8 +1546,13 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
debugEvent("AsOperator");
DartType type = pop();
Expression expression = popForValue();
- push(new KernelAsExpression(expression, type)
- ..fileOffset = offsetForToken(operator));
+ if (constantExpressionRequired) {
+ push(buildCompileTimeError(
+ "Not a constant expression.", operator.charOffset));
+ } else {
+ push(new KernelAsExpression(expression, type)
+ ..fileOffset = offsetForToken(operator));
+ }
}
@override
@@ -1565,7 +1570,12 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
typePromoter.handleIsCheck(isExpression, isInverted, operand.variable,
type, functionNestingLevel);
}
- push(isExpression);
+ if (constantExpressionRequired) {
+ push(buildCompileTimeError(
+ "Not a constant expression.", operator.charOffset));
+ } else {
+ push(isExpression);
+ }
}
@override
@@ -2908,6 +2918,10 @@ class DelayedAssignment extends ContextAccessor {
}
Expression handleAssignment(bool voidContext) {
+ if (helper.constantExpressionRequired) {
+ return helper.buildCompileTimeError(
+ "Not a constant expression.", offsetForToken(token));
+ }
if (identical("=", assignmentOperator)) {
return accessor.buildAssignment(value, voidContext: voidContext);
} else if (identical("+=", assignmentOperator)) {
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698