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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2985333002: fix #30290, assertion messages that contain `yield` (Closed)
Patch Set: merge and update status Created 3 years, 5 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 | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test-main.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 4ba4cbdba5a912adbacf5ba6aee2db3c77324c7a..18d5f7426613cf24a9e34846ac57937b8b6e3942 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -3957,19 +3957,20 @@ class CodeGenerator extends Object
var conditionType = condition.staticType;
JS.Expression jsCondition = _visit(condition);
- var assertHelper = 'assert';
if (conditionType is FunctionType &&
conditionType.parameters.isEmpty &&
conditionType.returnType == types.boolType) {
- jsCondition = new JS.Call(jsCondition, []);
+ jsCondition = _callHelper('test(#())', jsCondition);
} else if (conditionType != types.boolType) {
- assertHelper = 'dassert';
+ jsCondition = _callHelper('dassert(#)', jsCondition);
+ } else if (isNullable(condition)) {
+ jsCondition = _callHelper('test(#)', jsCondition);
}
- var args = [jsCondition];
- if (node.message != null) {
- args.add(js.call('() => #', [_visit(node.message)]));
- }
- return _callHelperStatement('$assertHelper(#);', [args]);
+ return js.statement(' if (!#) #.assertFailed(#);', [
+ jsCondition,
+ _runtimeModule,
+ node.message != null ? [_visit(node.message)] : []
+ ]);
}
@override
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/test-main.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698