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

Unified Diff: lib/runtime/dart_runtime.js

Issue 1149243002: Allow null args to dynamic invocations (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Created 5 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 | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/runtime/dart_runtime.js
diff --git a/lib/runtime/dart_runtime.js b/lib/runtime/dart_runtime.js
index 255d61964ea7f6c2923ccc2f359d1333c4eb336e..10c5981a868cd207b76ec016d0801e7250538c29 100644
--- a/lib/runtime/dart_runtime.js
+++ b/lib/runtime/dart_runtime.js
@@ -240,6 +240,10 @@ var dart, _js_helper, _js_primitives;
}
dart.is = instanceOf;
+ function instanceOfOrNull(obj, type) {
+ return (obj == null) || instanceOf(obj, type);
+ }
+
/**
* Computes the canonical type.
* This maps JS types onto their corresponding Dart Type.
@@ -465,17 +469,15 @@ var dart, _js_helper, _js_primitives;
if (actuals.length < this.args.length) return false;
var index = 0;
for(let i = 0; i < this.args.length; ++i) {
- let t = realRuntimeType(actuals[i]);
- if (!isSubtype(t, this.args[i])) return false;
+ if (!instanceOfOrNull(actuals[i], this.args[i])) return false;
++index;
}
if (actuals.length == this.args.length) return true;
let extras = actuals.length - this.args.length;
if (this.optionals.length > 0) {
if (extras > this.optionals.length) return false;
- for(let i = 0; i < extras; ++i) {
- let t = realRuntimeType(actuals[index + i]);
- if (!isSubtype(t, this.optionals[i])) return false;
+ for(let i = 0, j=index; i < extras; ++i, ++j) {
+ if (!instanceOfOrNull(actuals[j], this.optionals[i])) return false;
}
return true;
}
@@ -493,8 +495,7 @@ var dart, _js_helper, _js_primitives;
if (!(Object.prototype.hasOwnProperty.call(this.named, name))) {
return false;
}
- let t = realRuntimeType(opts[name]);
- if (!isSubtype(t, this.named[name])) return false;
+ if (!instanceOfOrNull(opts[name], this.named[name])) return false;
}
return true;
}
« no previous file with comments | « no previous file | lib/src/codegen/js_codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698