mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:39:48 +00:00
c9cf5b9916
The front end and analyzer use the same representation for types and type schemas, with the unknown type schema (`_`) treated as a pseudo-type. This creates the risk of accidentally mixing types and schemas, resulting in `_` accidentally "leaking" into the type system and showing up in static analysis results or error messages. As a step toward reducing this risk, this change adds a type parameter to `TypeAnalyzer`, preventing the shared type analysis code from being able to assume that types and schemas are represented the same. This extra discipline makes it much easier to search through the code and identify how types are manipulated vs. how type schemas are manipulated, and makes it impossible for the shared type analysis to accidentally leak `_` into the type system. I believe this change will also make it easier to implement some type inference improvements we've been contemplating, such as improved type inference of `.map(...).toList()`, as well as https://github.com/dart-lang/language/issues/3471, because those improvements may require introducing new kinds of type schemas. Change-Id: Ifcd7e2c4e1172ee39719ce8c8b10d7f10f6a7b6f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345353 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> |
||
---|---|---|
.. | ||
benchmarks | ||
lib/src | ||
outline_extraction_testcases | ||
parser_testcases | ||
test | ||
testcases | ||
tool | ||
analysis_options.yaml | ||
analysis_options_no_lints.yaml | ||
error_recovery.yaml | ||
LICENSE | ||
messages.status | ||
messages.yaml | ||
OWNERS | ||
PRESUBMIT.py | ||
pubspec.yaml | ||
README.md | ||
testing.json | ||
testing_with_lints.json |
Front end for Dart
This package provides a low-level API for use by compiler back ends that wish to implement the Dart language. It is intended for eventual use by dev_compiler, dart2js, and the Dart VM. In addition, it will share implementation details with the analyzer package--this will be accomplished by having the analyzer package import (and re-export) parts of this package's private implementation.
End-users should use the dart analyze
command-line tool to analyze their Dart code.
Integrators that want to write tools that analyze Dart code should use the analyzer package.
Note: A previous version of this package was published on pub.dev. It has now been marked DISCONTINUED as it is not intended for direct consumption, as per the notes above.