Do an extra round of type inference before resolving deferred closures. The order of operations for type inference of a generic invocation is now: 1. Create some constraints on type parameters by trying to match the return type of the invocation target as a subtype of the incoming type context. (For a constructor invocation, the return type of the invocation target is considered the raw uninstantiated type of the class enclosing the constructor declaration.) 2. Downwards inference: partially solve the set of type constraints accumulated in step 1, to produce a preliminary mapping of type parameters to type schemas. 3. Recursively infer all arguments to the invocation, except that if experimental feature `inference-update-1` is enabled, skip any arguments that are function literals (a.k.a. "closures"). Obtain the type contexts for the recursive inference by substituting the preliminary mapping (from step 2) into the corresponding parameter types of the invocation target. For each argument that is recursively inferred, create additional constraints on type parameters using the resulting static type. 4. If no arguments were skipped during step 3, go to step 7 (this always happens if `inference-update-1` is disabled). 5. Horizontal inference: partially solve the set of type constraints accumulated so far, to produce an updated preliminary mapping of type parameters to type schemas. 6. Recursively infer all of the invocation arguments that were previously skipped. As in step 3, obtain the type contexts for the recursive inference by substituting the preliminary mapping (this time from step 5) into the corresponding parameter types of the invocation target. Again, for each argument that is recursively inferred, create additional constraints on type parameters using the resulting static type. 7. Upwards inference: solve the set of type constraints accumulated so far, to produce a final mapping of type parameters to types. Check that each type is a subtype of the bound of its corresponding type parameter. 8. Check that the static type of each argument is assignable to the type obtained by substituting the final mapping (from step 7) into the corresponding parameter type of the invocation target. 9. Finally, obtain the static type of the invocation by substituting the final mapping (from step 7) into the return type of the invocation target. This addresses simpler cases of https://github.com/dart-lang/language/issues/731. Note that if experimental flag `inference-update-1` is disabled, the behavior is unchanged. Note that steps 2 and 5 use the same algorithm as each other (they only differ in how many type constraints have been accumulated so far), so I've renamed the function that performs it from `downwardsInfer` to `partialInfer`. Change-Id: I10d3288d4f4ba9e2b6bc18409186ddc67ca2ee9d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238881 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
Dart is:
Optimized for UI: Develop with a programming language specialized around the needs of user interface creation.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app.
Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents on our wiki.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.