Skip to content

Commit 740e819

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Record class modifiers in manifests.
Capture Dart class modifiers as part of the fine-grained manifest so ID matching and reuse reflect API-relevant changes. Modifiers like `abstract`, `base`, `final`, `interface`, `mixin class`, `mixin application`, and `sealed` affect subtyping and visibility rules; they must therefore participate in identity, matching, and dumps. Changes: - Extend `ClassItem` with boolean flags: `isAbstract`, `isBase`, `isFinal`, `isInterface`, `isMixinApplication`, `isMixinClass`, `isSealed`. - Include these flags in encode/decode/write and in `match(...)`. - Print a `flags:` block for classes in `LibraryManifestPrinter` when `withElementManifests` is enabled. - Bump `AnalysisDriver.DATA_VERSION` to 530 to invalidate caches and avoid reusing bundles with the old manifest layout. - Add tests exercising ID churn when modifiers change and updating expect output where flags are now printed. Impact: - Prevents stale ID reuse when class modifiers change. - Ensures downstream libraries re-link when modifier changes affect inheritance and implementability. - Improves diagnostic correctness and manifest transparency. Change-Id: I8914e4a9be18ea4fc0c6978029061e16aeb33e20 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447962 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent baa7da3 commit 740e819

File tree

4 files changed

+385
-1
lines changed

4 files changed

+385
-1
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 = 529;
109+
static const int DATA_VERSION = 530;
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/fine/manifest_item.dart

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ import 'package:collection/collection.dart';
1616
import 'package:meta/meta.dart';
1717

1818
class ClassItem extends InterfaceItem<ClassElementImpl> {
19+
final bool isAbstract;
20+
final bool isBase;
21+
final bool isFinal;
22+
final bool isInterface;
23+
final bool isMixinApplication;
24+
final bool isMixinClass;
25+
final bool isSealed;
26+
1927
ClassItem({
2028
required super.id,
2129
required super.metadata,
@@ -31,6 +39,13 @@ class ClassItem extends InterfaceItem<ClassElementImpl> {
3139
required super.mixins,
3240
required super.interfaces,
3341
required super.interface,
42+
required this.isAbstract,
43+
required this.isBase,
44+
required this.isFinal,
45+
required this.isInterface,
46+
required this.isMixinApplication,
47+
required this.isMixinClass,
48+
required this.isSealed,
3449
});
3550

3651
factory ClassItem.fromElement({
@@ -54,6 +69,13 @@ class ClassItem extends InterfaceItem<ClassElementImpl> {
5469
mixins: element.mixins.encode(context),
5570
interfaces: element.interfaces.encode(context),
5671
interface: ManifestInterface.empty(),
72+
isAbstract: element.isAbstract,
73+
isBase: element.isBase,
74+
isFinal: element.isFinal,
75+
isInterface: element.isInterface,
76+
isMixinApplication: element.isMixinApplication,
77+
isMixinClass: element.isMixinClass,
78+
isSealed: element.isSealed,
5779
);
5880
});
5981
}
@@ -74,8 +96,39 @@ class ClassItem extends InterfaceItem<ClassElementImpl> {
7496
mixins: ManifestType.readList(reader),
7597
interfaces: ManifestType.readList(reader),
7698
interface: ManifestInterface.read(reader),
99+
isAbstract: reader.readBool(),
100+
isBase: reader.readBool(),
101+
isFinal: reader.readBool(),
102+
isInterface: reader.readBool(),
103+
isMixinApplication: reader.readBool(),
104+
isMixinClass: reader.readBool(),
105+
isSealed: reader.readBool(),
77106
);
78107
}
108+
109+
@override
110+
bool match(MatchContext context, ClassElementImpl element) {
111+
return super.match(context, element) &&
112+
isAbstract == element.isAbstract &&
113+
isBase == element.isBase &&
114+
isFinal == element.isFinal &&
115+
isInterface == element.isInterface &&
116+
isMixinApplication == element.isMixinApplication &&
117+
isMixinClass == element.isMixinClass &&
118+
isSealed == element.isSealed;
119+
}
120+
121+
@override
122+
void write(BufferedSink sink) {
123+
super.write(sink);
124+
sink.writeBool(isAbstract);
125+
sink.writeBool(isBase);
126+
sink.writeBool(isFinal);
127+
sink.writeBool(isInterface);
128+
sink.writeBool(isMixinApplication);
129+
sink.writeBool(isMixinClass);
130+
sink.writeBool(isSealed);
131+
}
79132
}
80133

81134
class EnumItem extends InterfaceItem<EnumElementImpl> {

0 commit comments

Comments
 (0)