Skip to content

Commit c4f419c

Browse files
authored
[record_use] Fix positional argument semantic equality (dart-lang#2950)
1 parent a20185c commit c4f419c

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎pkgs/record_use/lib/src/reference.dart‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ final class CallWithArguments extends CallReference {
219219
}) {
220220
switch (other) {
221221
case CallWithArguments():
222+
if (positionalArguments.length != other.positionalArguments.length) {
223+
return false;
224+
}
222225
for (final (index, argument) in other.positionalArguments.indexed) {
223226
if (argument == null && allowMoreConstArguments) {
224227
continue;

‎pkgs/record_use/test/semantic_equality_test.dart‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,39 @@ void main() {
267267
isFalse,
268268
);
269269
});
270+
271+
test('CallWithArguments positional arguments different length', () {
272+
final recordings1 = Recordings(
273+
metadata: metadata,
274+
callsForDefinition: {
275+
definition1: [
276+
const CallWithArguments(
277+
positionalArguments: [IntConstant(1)],
278+
namedArguments: {},
279+
loadingUnit: null,
280+
location: Location(uri: 'package:a/a.dart', line: 1, column: 1),
281+
),
282+
],
283+
},
284+
instancesForDefinition: const {},
285+
);
286+
final recordings2 = Recordings(
287+
metadata: metadata,
288+
callsForDefinition: {
289+
definition1: [
290+
const CallWithArguments(
291+
positionalArguments: [IntConstant(1), IntConstant(2)],
292+
namedArguments: {},
293+
loadingUnit: null,
294+
location: Location(uri: 'package:a/a.dart', line: 1, column: 1),
295+
),
296+
],
297+
},
298+
instancesForDefinition: const {},
299+
);
300+
expect(
301+
recordings1.semanticEquals(recordings2),
302+
isFalse,
303+
);
304+
});
270305
}

0 commit comments

Comments
 (0)