@@ -66,13 +66,15 @@ class Object {
6666
6767 // Everything is an Object.
6868 @JSExportName ('is' )
69- static bool _is_Object (Object o) => true ;
69+ static bool _is_Object (Object o) => o != null ;
7070
7171 @JSExportName ('as' )
72- static Object _as_Object (Object o) => o;
72+ static Object _as_Object (Object o) =>
73+ o == null ? dart.cast (o, dart.unwrapType (Object ), false ) : o;
7374
7475 @JSExportName ('_check' )
75- static Object _check_Object (Object o) => o;
76+ static Object _check_Object (Object o) =>
77+ o == null ? dart.cast (o, dart.unwrapType (Object ), true ) : o;
7678}
7779
7880@patch
@@ -132,14 +134,14 @@ class Function {
132134 @JSExportName ('as' )
133135 static Object _as_Function (Object o) {
134136 // Avoid extra function call to core.Function.is() by manually inlining.
135- if (JS <bool >('!' , 'typeof $o == "function"' ) || o == null ) return o;
137+ if (JS <bool >('!' , 'typeof $o == "function"' )) return o;
136138 return dart.cast (o, dart.unwrapType (Function ), false );
137139 }
138140
139141 @JSExportName ('_check' )
140142 static Object _check_Function (Object o) {
141143 // Avoid extra function call to core.Function.is() by manually inlining.
142- if (JS <bool >('!' , 'typeof $o == "function"' ) || o == null ) return o;
144+ if (JS <bool >('!' , 'typeof $o == "function"' )) return o;
143145 return dart.cast (o, dart.unwrapType (Function ), true );
144146 }
145147}
@@ -211,8 +213,7 @@ class int {
211213 @JSExportName ('as' )
212214 static Object _as_int (Object o) {
213215 // Avoid extra function call to core.int.is() by manually inlining.
214- if (JS <bool >('!' , '(typeof $o == "number" && Math.floor($o ) == $o )' ) ||
215- o == null ) {
216+ if (JS <bool >('!' , '(typeof $o == "number" && Math.floor($o ) == $o )' )) {
216217 return o;
217218 }
218219 return dart.cast (o, dart.unwrapType (int ), false );
@@ -221,8 +222,7 @@ class int {
221222 @JSExportName ('_check' )
222223 static Object _check_int (Object o) {
223224 // Avoid extra function call to core.int.is() by manually inlining.
224- if (JS <bool >('!' , '(typeof $o == "number" && Math.floor($o ) == $o )' ) ||
225- o == null ) {
225+ if (JS <bool >('!' , '(typeof $o == "number" && Math.floor($o ) == $o )' )) {
226226 return o;
227227 }
228228 return dart.cast (o, dart.unwrapType (int ), true );
@@ -250,14 +250,14 @@ class double {
250250 @JSExportName ('as' )
251251 static Object _as_double (o) {
252252 // Avoid extra function call to core.double.is() by manually inlining.
253- if (JS <bool >('!' , 'typeof $o == "number"' ) || o == null ) return o;
253+ if (JS <bool >('!' , 'typeof $o == "number"' )) return o;
254254 return dart.cast (o, dart.unwrapType (double ), false );
255255 }
256256
257257 @JSExportName ('_check' )
258258 static Object _check_double (o) {
259259 // Avoid extra function call to core.double.is() by manually inlining.
260- if (JS <bool >('!' , 'typeof $o == "number"' ) || o == null ) return o;
260+ if (JS <bool >('!' , 'typeof $o == "number"' )) return o;
261261 return dart.cast (o, dart.unwrapType (double ), true );
262262 }
263263}
@@ -272,14 +272,14 @@ abstract class num implements Comparable<num> {
272272 @JSExportName ('as' )
273273 static Object _as_num (o) {
274274 // Avoid extra function call to core.num.is() by manually inlining.
275- if (JS <bool >('!' , 'typeof $o == "number"' ) || o == null ) return o;
275+ if (JS <bool >('!' , 'typeof $o == "number"' )) return o;
276276 return dart.cast (o, dart.unwrapType (num ), false );
277277 }
278278
279279 @JSExportName ('_check' )
280280 static Object _check_num (o) {
281281 // Avoid extra function call to core.num.is() by manually inlining.
282- if (JS <bool >('!' , 'typeof $o == "number"' ) || o == null ) return o;
282+ if (JS <bool >('!' , 'typeof $o == "number"' )) return o;
283283 return dart.cast (o, dart.unwrapType (num ), true );
284284 }
285285}
@@ -652,14 +652,14 @@ class String {
652652 @JSExportName ('as' )
653653 static Object _as_String (Object o) {
654654 // Avoid extra function call to core.String.is() by manually inlining.
655- if (JS <bool >('!' , 'typeof $o == "string"' ) || o == null ) return o;
655+ if (JS <bool >('!' , 'typeof $o == "string"' )) return o;
656656 return dart.cast (o, dart.unwrapType (String ), false );
657657 }
658658
659659 @JSExportName ('_check' )
660660 static Object _check_String (Object o) {
661661 // Avoid extra function call to core.String.is() by manually inlining.
662- if (JS <bool >('!' , 'typeof $o == "string"' ) || o == null ) return o;
662+ if (JS <bool >('!' , 'typeof $o == "string"' )) return o;
663663 return dart.cast (o, dart.unwrapType (String ), true );
664664 }
665665}
@@ -683,14 +683,14 @@ class bool {
683683 @JSExportName ('as' )
684684 static Object _as_bool (Object o) {
685685 // Avoid extra function call to core.bool.is() by manually inlining.
686- if (JS <bool >("!" , '$o === true || $o === false' ) || o == null ) return o;
686+ if (JS <bool >("!" , '$o === true || $o === false' )) return o;
687687 return dart.cast (o, dart.unwrapType (bool ), false );
688688 }
689689
690690 @JSExportName ('_check' )
691691 static Object _check_bool (Object o) {
692692 // Avoid extra function call to core.bool.is() by manually inlining.
693- if (JS <bool >("!" , '$o === true || $o === false' ) || o == null ) return o;
693+ if (JS <bool >("!" , '$o === true || $o === false' )) return o;
694694 return dart.cast (o, dart.unwrapType (bool ), true );
695695 }
696696}
0 commit comments