Skip to content

Commit 2b13268

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Track constructor/method/top-level function APIs.
Fine-grained dependency tracking missed several element APIs and edge cases. This change annotates and records usage of key properties on `ConstructorElementImpl`, `MethodElementImpl`, and `TopLevelFunctionElementImpl`, and extends the manifest/serialization to capture relationships and inference state that affect API shape. What’s included - Add `@elementClass` and granular tracking on members: - Mark identifiers and flags with `@trackedIncludedInId`. - Mark getters like `firstFragment`, `fragments`, `lastFragment`, `accept()`, `visitChildren()` as `@trackedDirectlyOpaque` and record opaque API use. - Mark derived properties as `@trackedIndirectly` and internal caches as `@trackedInternal`. - Expose `_fragments` lists so tracked access doesn’t bypass recording. - Constructors: - Track `isConst`, `isFactory`, `constantInitializers`. - Persist and match `redirectedConstructor` and `superConstructor` via new optional `ManifestElement` fields. - Compute `isGenerative` as `!isFactory` to avoid fragment drift. - Methods: - Persist `isOperatorEqualWithParameterTypeFromObject`. - Serialize `typeInferenceError` and surface it in manifests. - Add binary I/O for `TopLevelInferenceError` (read/write/optional, equality) and print it in result output. - Extend `ManifestElement` with `encodeOptional()/readOptional()` and a helper extension for matching/writing optionals. - Update the result printer to show: - Method flags and optional `typeInferenceError`. - Constructor `redirectedConstructor` and `superConstructor`. - Bump `AnalysisDriver.DATA_VERSION` to 547 to invalidate old caches. - Minor fixes: - Use `baseElement.firstFragmentLocation.libraryFragment!.source` when wiring the diagnostic reporter in constant evaluation to align with fragment locations. Why Clients of the fine-grained dependency system rely on accurate identification and usage tracking of element APIs. Missing tracking for fragments/visitors and absent manifest fields (constructor redirection/ super calls, method inference errors) could let incompatible API changes slip past invalidation and requirement checks. Persisting these details ensures correct cache keys, precise requirement verification, and more actionable diagnostics. Compatibility - Data/summary format changes require a cache rebuild (version 547). - No user-visible API changes. Change-Id: Ifdc1a97e87dc6e2decabcf0d9a9c634825da6e85 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448900 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent fc1bd94 commit 2b13268

File tree

8 files changed

+773
-221
lines changed

8 files changed

+773
-221
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ testFineAfterLibraryAnalyzerHook;
106106
// TODO(scheglov): Clean up the list of implicitly analyzed files.
107107
class AnalysisDriver {
108108
/// The version of data format, should be incremented on every format change.
109-
static const int DATA_VERSION = 546;
109+
static const int DATA_VERSION = 547;
110110

111111
/// The number of exception contexts allowed to write. Once this field is
112112
/// zero, we stop writing any new exception contexts in this process.

pkg/analyzer/lib/src/dart/constant/evaluation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2811,7 +2811,7 @@ class _InstanceCreationEvaluator {
28112811
late final DiagnosticReporter _externalDiagnosticReporter =
28122812
DiagnosticReporter(
28132813
_externalDiagnosticListener,
2814-
_constructor.firstFragment.libraryFragment.source,
2814+
_constructor.baseElement.firstFragmentLocation.libraryFragment!.source,
28152815
);
28162816

28172817
late final ConstantVisitor _initializerVisitor = ConstantVisitor(

0 commit comments

Comments
 (0)