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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 '` with type arguments <' + $typeArgs + '> is not supported.'); | 239 '` with type arguments <' + $typeArgs + '> is not supported.'); |
240 } | 240 } |
241 return $f.apply($obj, $args); | 241 return $f.apply($obj, $args); |
242 } | 242 } |
243 | 243 |
244 // Apply type arguments | 244 // Apply type arguments |
245 if ($ftype instanceof $GenericFunctionType) { | 245 if ($ftype instanceof $GenericFunctionType) { |
246 let formalCount = $ftype.formalCount; | 246 let formalCount = $ftype.formalCount; |
247 | 247 |
248 if ($typeArgs == null) { | 248 if ($typeArgs == null) { |
249 $typeArgs = $ftype.instantiateDefaultBounds(); | 249 // TODO(jmesserly): this should use instantiate to bounds logic. |
| 250 // See https://github.com/dart-lang/sdk/issues/27256 |
| 251 $typeArgs = Array(formalCount).fill($dynamic); |
250 } else if ($typeArgs.length != formalCount) { | 252 } else if ($typeArgs.length != formalCount) { |
251 // TODO(jmesserly): is this the right error? | 253 // TODO(jmesserly): is this the right error? |
252 $throwStrongModeError( | 254 $throwStrongModeError( |
253 'incorrect number of arguments to generic function ' + | 255 'incorrect number of arguments to generic function ' + |
254 $typeName($ftype) + ', got <' + $typeArgs + '> expected ' + | 256 $typeName($ftype) + ', got <' + $typeArgs + '> expected ' + |
255 formalCount + '.'); | 257 formalCount + '.'); |
256 } | 258 } |
| 259 // Instantiate the function type. |
257 $ftype = $ftype.instantiate($typeArgs); | 260 $ftype = $ftype.instantiate($typeArgs); |
258 } else if ($typeArgs != null) { | 261 } else if ($typeArgs != null) { |
259 $throwStrongModeError( | 262 $throwStrongModeError( |
260 'got type arguments to non-generic function ' + $typeName($ftype) + | 263 'got type arguments to non-generic function ' + $typeName($ftype) + |
261 ', got <' + $typeArgs + '> expected none.'); | 264 ', got <' + $typeArgs + '> expected none.'); |
262 } | 265 } |
263 | 266 |
264 if ($_checkApply($ftype, $args)) { | 267 if ($_checkApply($ftype, $args)) { |
265 if ($typeArgs != null) { | 268 if ($typeArgs != null) { |
266 return $f.apply($obj, $typeArgs).apply($obj, $args); | 269 return $f.apply($obj, $typeArgs).apply($obj, $args); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 name = '+' + name; | 911 name = '+' + name; |
909 } | 912 } |
910 return name; | 913 return name; |
911 } | 914 } |
912 | 915 |
913 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 916 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
914 /// | 917 /// |
915 /// Libraries are not actually deferred in DDC, so this just returns a future | 918 /// Libraries are not actually deferred in DDC, so this just returns a future |
916 /// that completes immediately. | 919 /// that completes immediately. |
917 Future loadLibrary() => new Future.value(); | 920 Future loadLibrary() => new Future.value(); |
OLD | NEW |