From 5b45c6ef872707970183e9c8ade8e764d6b1868d Mon Sep 17 00:00:00 2001 From: John Messerly Date: Tue, 19 Jan 2016 12:02:06 -0800 Subject: [PATCH] partial fix for #414, avoid dcall in _convertToDart this doesn't fix the root call, but still, it's nice to clean up this dead code R=vsm@google.com Review URL: https://codereview.chromium.org/1609843002 . --- pkg/dev_compiler/lib/runtime/dart/js.js | 8 +++----- .../test/codegen/expect/collection/wrappers.txt | 6 +++--- .../tool/input_sdk/lib/js/dart2js/js_dart2js.dart | 5 ++--- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/dev_compiler/lib/runtime/dart/js.js b/pkg/dev_compiler/lib/runtime/dart/js.js index 7568271f5693..be51648dff61 100644 --- a/pkg/dev_compiler/lib/runtime/dart/js.js +++ b/pkg/dev_compiler/lib/runtime/dart/js.js @@ -343,10 +343,8 @@ dart_library.library('dart/js', null, /* Imports */[ return wrapper; } dart.fn(_wrapDartFunction); - function _convertToDart(o, isBrowserType) { - if (isBrowserType === void 0) isBrowserType = null; - if (isBrowserType == null) isBrowserType = _isBrowserType; - if (o == null || typeof o == "string" || typeof o == "number" || typeof o == "boolean" || dart.notNull(dart.dcall(isBrowserType, o))) { + function _convertToDart(o) { + if (o == null || typeof o == "string" || typeof o == "number" || typeof o == "boolean" || dart.notNull(_isBrowserType(o))) { return o; } else if (o instanceof Date) { let ms = o.getTime(); @@ -357,7 +355,7 @@ dart_library.library('dart/js', null, /* Imports */[ return _putIfAbsent(_dartProxies, o, _wrapToDart); } } - dart.fn(_convertToDart, core.Object, [dart.dynamic], [dart.functionType(core.bool, [dart.dynamic])]); + dart.fn(_convertToDart, core.Object, [dart.dynamic]); function _wrapToDart(o) { if (typeof o == "function") { return new JsFunction._fromJs(o); diff --git a/pkg/dev_compiler/test/codegen/expect/collection/wrappers.txt b/pkg/dev_compiler/test/codegen/expect/collection/wrappers.txt index dd3439aec59c..56eb8f0994bf 100644 --- a/pkg/dev_compiler/test/codegen/expect/collection/wrappers.txt +++ b/pkg/dev_compiler/test/codegen/expect/collection/wrappers.txt @@ -1,17 +1,17 @@ // Messages from compiling wrappers.dart severe: [INVALID_METHOD_OVERRIDE] Invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable) → Iterable) is not a subtype of Iterable.expand (((E) → Iterable) → Iterable). (package:collection/wrappers.dart, line 41, col 3) severe: [INVALID_METHOD_OVERRIDE] Invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable) is not a subtype of Iterable.map (((E) → T) → Iterable). (package:collection/wrappers.dart, line 68, col 3) -severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 117, col 7) +severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 117, col 7) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable) → Iterable) is not a subtype of Iterable.expand (((E) → Iterable) → Iterable). (package:collection/wrappers.dart, line 117, col 25) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable) is not a subtype of Iterable.map (((E) → T) → Iterable). (package:collection/wrappers.dart, line 117, col 25) severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 216, col 7) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable) → Iterable) is not a subtype of Iterable.expand (((E) → Iterable) → Iterable). (package:collection/wrappers.dart, line 216, col 24) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable) is not a subtype of Iterable.map (((E) → T) → Iterable). (package:collection/wrappers.dart, line 216, col 24) -severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 269, col 7) +severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 269, col 7) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((E) → Iterable) → Iterable) is not a subtype of Iterable.expand (((E) → Iterable) → Iterable). (package:collection/wrappers.dart, line 269, col 26) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((E) → dynamic) → Iterable) is not a subtype of Iterable.map (((E) → T) → Iterable). (package:collection/wrappers.dart, line 269, col 26) severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 367, col 7) -severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.expand' and 'Iterable.map' (package:collection/wrappers.dart, line 452, col 7) +severe: [AnalyzerMessage] Missing concrete implementation of 'Iterable.map' and 'Iterable.expand' (package:collection/wrappers.dart, line 452, col 7) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.expand (((V) → Iterable) → Iterable) is not a subtype of Iterable.expand (((V) → Iterable) → Iterable). (package:collection/wrappers.dart, line 452, col 25) severe: [INVALID_METHOD_OVERRIDE] Base class introduces an invalid override. The type of _DelegatingIterableBase.map (((V) → dynamic) → Iterable) is not a subtype of Iterable.map (((V) → T) → Iterable). (package:collection/wrappers.dart, line 452, col 25) warning: [DOWN_CAST_COMPOSITE] _base.fold(initialValue, combine) (dynamic) will need runtime check to cast to type T (package:collection/wrappers.dart, line 49, col 7) diff --git a/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart b/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart index 08449bd25534..da084509b494 100644 --- a/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart +++ b/pkg/dev_compiler/tool/input_sdk/lib/js/dart2js/js_dart2js.dart @@ -475,13 +475,12 @@ dynamic _wrapDartFunction(f) { // converts a Dart object to a reference to a native JS object // which might be a DartObject JS->Dart proxy -Object _convertToDart(o, [bool isBrowserType(x)]) { - if (isBrowserType == null) isBrowserType = _isBrowserType; +Object _convertToDart(o) { if (JS('bool', '# == null', o) || JS('bool', 'typeof # == "string"', o) || JS('bool', 'typeof # == "number"', o) || JS('bool', 'typeof # == "boolean"', o) || - isBrowserType(o)) { + _isBrowserType(o)) { return o; } else if (JS('bool', '# instanceof Date', o)) { var ms = JS('num', '#.getTime()', o);