| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// This library defines runtime operations on objects used by the code | 5 /// This library defines runtime operations on objects used by the code |
| 6 /// generator. | 6 /// generator. |
| 7 part of dart._runtime; | 7 part of dart._runtime; |
| 8 | 8 |
| 9 class InvocationImpl extends Invocation { | 9 class InvocationImpl extends Invocation { |
| 10 final Symbol memberName; | 10 final Symbol memberName; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 }; | 463 }; |
| 464 })()'''); | 464 })()'''); |
| 465 | 465 |
| 466 final _ignoreTypeFailure = JS( | 466 final _ignoreTypeFailure = JS( |
| 467 '', | 467 '', |
| 468 '''(() => { | 468 '''(() => { |
| 469 return $_ignoreMemo((actual, type) => { | 469 return $_ignoreMemo((actual, type) => { |
| 470 // TODO(vsm): Remove this hack ... | 470 // TODO(vsm): Remove this hack ... |
| 471 // This is primarily due to the lack of generic methods, | 471 // This is primarily due to the lack of generic methods, |
| 472 // but we need to triage all the types. | 472 // but we need to triage all the types. |
| 473 if ($_isFutureOr(type)) { |
| 474 // Ignore if we would ignore either side of union. |
| 475 let typeArg = $getGenericArgs(type)[0]; |
| 476 let typeFuture = ${getGenericClass(Future)}(typeArg); |
| 477 return $_ignoreTypeFailure(actual, typeFuture) || |
| 478 $_ignoreTypeFailure(actual, typeArg); |
| 479 } |
| 480 |
| 473 if (!!$isSubtype(type, $Iterable) && !!$isSubtype(actual, $Iterable) || | 481 if (!!$isSubtype(type, $Iterable) && !!$isSubtype(actual, $Iterable) || |
| 474 !!$isSubtype(type, $FutureOr) && !!$isSubtype(actual, $Future) || | 482 !!$isSubtype(type, $Future) && !!$isSubtype(actual, $Future) || |
| 475 !!$isSubtype(type, $Map) && !!$isSubtype(actual, $Map) || | 483 !!$isSubtype(type, $Map) && !!$isSubtype(actual, $Map) || |
| 476 $isFunctionType(type) && $isFunctionType(actual) || | 484 $isFunctionType(type) && $isFunctionType(actual) || |
| 477 !!$isSubtype(type, $Stream) && !!$isSubtype(actual, $Stream) || | 485 !!$isSubtype(type, $Stream) && !!$isSubtype(actual, $Stream) || |
| 478 !!$isSubtype(type, $StreamSubscription) && | 486 !!$isSubtype(type, $StreamSubscription) && |
| 479 !!$isSubtype(actual, $StreamSubscription)) { | 487 !!$isSubtype(actual, $StreamSubscription)) { |
| 480 console.warn('Ignoring cast fail from ' + $typeName(actual) + | 488 console.warn('Ignoring cast fail from ' + $typeName(actual) + |
| 481 ' to ' + $typeName(type)); | 489 ' to ' + $typeName(type)); |
| 482 return true; | 490 return true; |
| 483 } | 491 } |
| 484 return false; | 492 return false; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 name = '+' + name; | 983 name = '+' + name; |
| 976 } | 984 } |
| 977 return name; | 985 return name; |
| 978 } | 986 } |
| 979 | 987 |
| 980 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 988 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
| 981 /// | 989 /// |
| 982 /// Libraries are not actually deferred in DDC, so this just returns a future | 990 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 983 /// that completes immediately. | 991 /// that completes immediately. |
| 984 Future loadLibrary() => new Future.value(); | 992 Future loadLibrary() => new Future.value(); |
| OLD | NEW |