dart-sdk/pkg/front_end
Paul Berry c9cf5b9916 Add a type parameter to TypeAnalyzer to represent type schemas.
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>
2024-01-18 15:28:25 +00:00
..
benchmarks
lib/src Add a type parameter to TypeAnalyzer to represent type schemas. 2024-01-18 15:28:25 +00:00
outline_extraction_testcases
parser_testcases [cfe] Report error on covariant in extension type methods 2023-12-15 09:13:07 +00:00
test [CFE] Strong/weak suites takes error-and-ok-comments into account 2024-01-18 14:40:08 +00:00
testcases [CFE] Strong/weak suites takes error-and-ok-comments into account 2024-01-18 14:40:08 +00:00
tool Revert "[cfe] Run fasta testing directly" 2024-01-10 11:46:47 +00:00
analysis_options.yaml
analysis_options_no_lints.yaml [cfe] Add CFE test for DartScope 2023-11-15 10:17:23 +00:00
error_recovery.yaml
LICENSE
messages.status [cfe] Show when syntax was unhandled in the error message 2024-01-11 15:02:29 +00:00
messages.yaml [cfe] Show when syntax was unhandled in the error message 2024-01-11 15:02:29 +00:00
OWNERS Also add global owners to CFE/VM packages 2023-11-27 14:35:52 +00:00
PRESUBMIT.py [build] Python 3.12 compatibility. 2023-12-12 18:19:35 +00:00
pubspec.yaml
README.md
testing.json [CFE] Remove unused fasta/sdk_test.dart 2024-01-16 13:18:57 +00:00
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.