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

Unified Diff: lib/src/codegen/js_codegen.dart

Issue 1261783005: fixes #197, don't generate casts that always pass (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 4 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 | test/codegen/expect/js_test.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/codegen/js_codegen.dart
diff --git a/lib/src/codegen/js_codegen.dart b/lib/src/codegen/js_codegen.dart
index 8a769573489637c8247f625e89d4fc13b699bf65..4f9878a4fcec5d80451788ed1acbd417f027b36d 100644
--- a/lib/src/codegen/js_codegen.dart
+++ b/lib/src/codegen/js_codegen.dart
@@ -253,6 +253,9 @@ class JSCodegenVisitor extends GeneralizingAstVisitor {
var from = getStaticType(node.expression);
var to = node.type.type;
+ // Skip the cast if it's not needed.
+ if (rules.isSubTypeOf(from, to)) return _visit(node.expression);
+
// All Dart number types map to a JS double.
if (rules.isNumType(from) &&
(rules.isIntType(to) || rules.isDoubleType(to))) {
« no previous file with comments | « no previous file | test/codegen/expect/js_test.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698