Skip to content

Commit 3172a7c

Browse files
scheglovCommit Queue
authored andcommitted
Fine. Track mixin base flag and super-invoked names.
Capture additional mixin semantics in the fine-grained manifest to improve dependency sensitivity and determinism. - Add `isBase` to `MixinItem` and include it in encode/read/match/write, so manifest IDs change when a mixin’s base modifier changes. - Record `superInvokedNames` in `MixinItem` as a `List<LookupName>` and include it in matching, making the manifest sensitive to whether a mixin invokes a member on `super` (getter, setter, or method). - Canonicalize `superInvokedNames` by sorting them during collection in `LibraryBuilder.collectMixinSuperInvokedNames()`, eliminating nondeterminism from source reordering. - Add `SummaryDataReader.readLookupNameList()` to simplify decoding of `LookupName` lists. - Bump `AnalysisDriver.DATA_VERSION` to 532 to reflect the binary format change and invalidate incompatible caches. These changes ensure that altering a mixin’s base status or its use of `super` correctly affects manifest identity, while simple reordering of `super` calls does not. Change-Id: I9147f6505070f28ffbc476acac3cdaaaf55c2fc1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448000 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent b54e38e commit 3172a7c

File tree

5 files changed

+519
-3
lines changed

5 files changed

+519
-3
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 = 531;
109+
static const int DATA_VERSION = 532;
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/lookup_name.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ extension SummaryDataReaderExtension on SummaryDataReader {
163163
return result;
164164
}
165165

166+
List<LookupName> readLookupNameList() {
167+
return readTypedList(() => LookupName.read(this));
168+
}
169+
166170
Set<LookupName> readLookupNameSet() {
167171
var length = readUInt30();
168172
var result = <LookupName>{};

pkg/analyzer/lib/src/fine/manifest_item.dart

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,9 @@ class ManifestMetadata {
11761176
}
11771177

11781178
class MixinItem extends InterfaceItem<MixinElementImpl> {
1179+
final bool isBase;
11791180
final List<ManifestType> superclassConstraints;
1181+
final List<LookupName> superInvokedNames;
11801182

11811183
MixinItem({
11821184
required super.id,
@@ -1193,7 +1195,9 @@ class MixinItem extends InterfaceItem<MixinElementImpl> {
11931195
required super.declaredConstructors,
11941196
required super.inheritedConstructors,
11951197
required super.interface,
1198+
required this.isBase,
11961199
required this.superclassConstraints,
1200+
required this.superInvokedNames,
11971201
}) : assert(supertype == null),
11981202
assert(mixins.isEmpty),
11991203
assert(superclassConstraints.isNotEmpty);
@@ -1219,7 +1223,11 @@ class MixinItem extends InterfaceItem<MixinElementImpl> {
12191223
supertype: element.supertype?.encode(context),
12201224
mixins: element.mixins.encode(context),
12211225
interfaces: element.interfaces.encode(context),
1226+
isBase: element.isBase,
12221227
superclassConstraints: element.superclassConstraints.encode(context),
1228+
superInvokedNames: element.superInvokedNames
1229+
.map((name) => name.asLookupName)
1230+
.toFixedList(),
12231231
);
12241232
});
12251233
}
@@ -1240,20 +1248,29 @@ class MixinItem extends InterfaceItem<MixinElementImpl> {
12401248
mixins: ManifestType.readList(reader),
12411249
interfaces: ManifestType.readList(reader),
12421250
interface: ManifestInterface.read(reader),
1251+
isBase: reader.readBool(),
12431252
superclassConstraints: ManifestType.readList(reader),
1253+
superInvokedNames: reader.readLookupNameList(),
12441254
);
12451255
}
12461256

12471257
@override
12481258
bool match(MatchContext context, MixinElementImpl element) {
12491259
return super.match(context, element) &&
1250-
superclassConstraints.match(context, element.superclassConstraints);
1260+
isBase == element.isBase &&
1261+
superclassConstraints.match(context, element.superclassConstraints) &&
1262+
const IterableEquality<String>().equals(
1263+
superInvokedNames.map((lookupName) => lookupName.asString),
1264+
element.superInvokedNames,
1265+
);
12511266
}
12521267

12531268
@override
12541269
void write(BufferedSink sink) {
12551270
super.write(sink);
1271+
sink.writeBool(isBase);
12561272
superclassConstraints.writeList(sink);
1273+
superInvokedNames.write(sink);
12571274
}
12581275
}
12591276

pkg/analyzer/lib/src/summary2/library_builder.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import 'package:analyzer/src/summary2/types_builder.dart';
2828
import 'package:analyzer/src/util/performance/operation_performance.dart';
2929
import 'package:analyzer/src/utilities/extensions/collection.dart';
3030
import 'package:analyzer/src/utilities/extensions/element.dart';
31+
import 'package:collection/collection.dart';
3132

3233
class DefiningLinkingUnit extends LinkingUnit {
3334
DefiningLinkingUnit({required super.node, required super.element});
@@ -277,7 +278,7 @@ class LibraryBuilder {
277278
}
278279
}
279280
var fragment = declaration.declaredFragment!;
280-
fragment.superInvokedNames = names.toList();
281+
fragment.superInvokedNames = names.sorted();
281282
}
282283
}
283284
}

0 commit comments

Comments
 (0)