Skip to content

Commit dfa1ea5

Browse files
scheglovCommit Queue
authored and
Commit Queue
committed
Fine. Separate InstanceMethodIdMismatch and InterfaceConstructorIdMismatch.
Change-Id: Ie2015c764edbf17f0f9d154893357e7d69ec9e24 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423763 Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 897d801 commit dfa1ea5

File tree

4 files changed

+91
-64
lines changed

4 files changed

+91
-64
lines changed

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

+20-4
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,33 @@ final class ExportLibraryMissing extends ExportFailure {
4444
ExportLibraryMissing({required this.uri});
4545
}
4646

47-
class InstanceMemberIdMismatch extends RequirementFailure {
47+
class InstanceMethodIdMismatch extends RequirementFailure {
4848
final Uri libraryUri;
4949
final LookupName interfaceName;
50-
final LookupName memberName;
50+
final LookupName methodName;
5151
final ManifestItemId? expectedId;
5252
final ManifestItemId? actualId;
5353

54-
InstanceMemberIdMismatch({
54+
InstanceMethodIdMismatch({
5555
required this.libraryUri,
5656
required this.interfaceName,
57-
required this.memberName,
57+
required this.methodName,
58+
required this.expectedId,
59+
required this.actualId,
60+
});
61+
}
62+
63+
class InterfaceConstructorIdMismatch extends RequirementFailure {
64+
final Uri libraryUri;
65+
final LookupName interfaceName;
66+
final LookupName constructorName;
67+
final ManifestItemId? expectedId;
68+
final ManifestItemId? actualId;
69+
70+
InterfaceConstructorIdMismatch({
71+
required this.libraryUri,
72+
required this.interfaceName,
73+
required this.constructorName,
5874
required this.expectedId,
5975
required this.actualId,
6076
});

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

+17-15
Original file line numberDiff line numberDiff line change
@@ -315,32 +315,34 @@ class RequirementsManifest {
315315
);
316316
}
317317

318-
for (var methodEntry in interfaceEntry.value.constructors.entries) {
319-
var memberName = methodEntry.key;
320-
var memberId = interfaceItem.getMemberId(memberName);
321-
var expectedId = methodEntry.value;
322-
if (expectedId != memberId) {
323-
return InstanceMemberIdMismatch(
318+
var constructors = interfaceEntry.value.constructors;
319+
for (var constructorEntry in constructors.entries) {
320+
var constructorName = constructorEntry.key;
321+
var constructorId = interfaceItem.getMemberId(constructorName);
322+
var expectedId = constructorEntry.value;
323+
if (expectedId != constructorId) {
324+
return InterfaceConstructorIdMismatch(
324325
libraryUri: libraryUri,
325326
interfaceName: interfaceName,
326-
memberName: memberName,
327+
constructorName: constructorName,
327328
expectedId: expectedId,
328-
actualId: memberId,
329+
actualId: constructorId,
329330
);
330331
}
331332
}
332333

333-
for (var methodEntry in interfaceEntry.value.methods.entries) {
334-
var memberName = methodEntry.key;
335-
var memberId = interfaceItem.getMemberId(memberName);
334+
var methods = interfaceEntry.value.methods;
335+
for (var methodEntry in methods.entries) {
336+
var methodName = methodEntry.key;
337+
var methodId = interfaceItem.getMemberId(methodName);
336338
var expectedId = methodEntry.value;
337-
if (expectedId != memberId) {
338-
return InstanceMemberIdMismatch(
339+
if (expectedId != methodId) {
340+
return InstanceMethodIdMismatch(
339341
libraryUri: libraryUri,
340342
interfaceName: interfaceName,
341-
memberName: memberName,
343+
methodName: methodName,
342344
expectedId: expectedId,
343-
actualId: memberId,
345+
actualId: methodId,
344346
);
345347
}
346348
}

pkg/analyzer/test/src/dart/analysis/driver_test.dart

+42-42
Original file line numberDiff line numberDiff line change
@@ -5535,10 +5535,10 @@ class A {
55355535
[operation] readLibraryCycleBundle
55365536
package:test/test.dart
55375537
[operation] getErrorsCannotReuse
5538-
instanceMemberIdMismatch
5538+
interfaceConstructorIdMismatch
55395539
libraryUri: package:test/a.dart
55405540
interfaceName: A
5541-
memberName: named
5541+
constructorName: named
55425542
expectedId: #M1
55435543
actualId: #M4
55445544
[operation] analyzeFile
@@ -5641,10 +5641,10 @@ class A {
56415641
[operation] readLibraryCycleBundle
56425642
package:test/test.dart
56435643
[operation] getErrorsCannotReuse
5644-
instanceMemberIdMismatch
5644+
interfaceConstructorIdMismatch
56455645
libraryUri: package:test/a.dart
56465646
interfaceName: A
5647-
memberName: c2
5647+
constructorName: c2
56485648
expectedId: <null>
56495649
actualId: #M3
56505650
[operation] analyzeFile
@@ -5839,10 +5839,10 @@ class A {
58395839
[operation] readLibraryCycleBundle
58405840
package:test/test.dart
58415841
[operation] getErrorsCannotReuse
5842-
instanceMemberIdMismatch
5842+
interfaceConstructorIdMismatch
58435843
libraryUri: package:test/a.dart
58445844
interfaceName: A
5845-
memberName: c2
5845+
constructorName: c2
58465846
expectedId: #M2
58475847
actualId: <null>
58485848
[operation] analyzeFile
@@ -5961,10 +5961,10 @@ class A {
59615961
uri: package:test/test.dart
59625962
flags: isLibrary
59635963
[operation] cannotReuseLinkedBundle
5964-
instanceMemberIdMismatch
5964+
interfaceConstructorIdMismatch
59655965
libraryUri: package:test/a.dart
59665966
interfaceName: A
5967-
memberName: named
5967+
constructorName: named
59685968
expectedId: #M1
59695969
actualId: #M5
59705970
[operation] linkLibraryCycle
@@ -5987,10 +5987,10 @@ class A {
59875987
constructors
59885988
named: #M5
59895989
[operation] getErrorsCannotReuse
5990-
instanceMemberIdMismatch
5990+
interfaceConstructorIdMismatch
59915991
libraryUri: package:test/a.dart
59925992
interfaceName: A
5993-
memberName: named
5993+
constructorName: named
59945994
expectedId: #M1
59955995
actualId: #M5
59965996
[operation] analyzeFile
@@ -6099,10 +6099,10 @@ class A {
60996099
[operation] readLibraryCycleBundle
61006100
package:test/test.dart
61016101
[operation] getErrorsCannotReuse
6102-
instanceMemberIdMismatch
6102+
interfaceConstructorIdMismatch
61036103
libraryUri: package:test/a.dart
61046104
interfaceName: A
6105-
memberName: new
6105+
constructorName: new
61066106
expectedId: #M1
61076107
actualId: #M4
61086108
[operation] analyzeFile
@@ -6631,10 +6631,10 @@ class A {
66316631
[operation] readLibraryCycleBundle
66326632
package:test/test.dart
66336633
[operation] getErrorsCannotReuse
6634-
instanceMemberIdMismatch
6634+
instanceMethodIdMismatch
66356635
libraryUri: package:test/a.dart
66366636
interfaceName: A
6637-
memberName: foo
6637+
methodName: foo
66386638
expectedId: #M1
66396639
actualId: #M4
66406640
[operation] analyzeFile
@@ -7446,10 +7446,10 @@ class A {
74467446
[operation] readLibraryCycleBundle
74477447
package:test/test.dart
74487448
[operation] getErrorsCannotReuse
7449-
instanceMemberIdMismatch
7449+
instanceMethodIdMismatch
74507450
libraryUri: package:test/a.dart
74517451
interfaceName: A
7452-
memberName: foo
7452+
methodName: foo
74537453
expectedId: <null>
74547454
actualId: #M2
74557455
[operation] analyzeFile
@@ -8115,10 +8115,10 @@ class A {}
81158115
[operation] readLibraryCycleBundle
81168116
package:test/test.dart
81178117
[operation] getErrorsCannotReuse
8118-
instanceMemberIdMismatch
8118+
instanceMethodIdMismatch
81198119
libraryUri: package:test/a.dart
81208120
interfaceName: A
8121-
memberName: foo
8121+
methodName: foo
81228122
expectedId: #M1
81238123
actualId: <null>
81248124
[operation] analyzeFile
@@ -8239,10 +8239,10 @@ class A {
82398239
[operation] readLibraryCycleBundle
82408240
package:test/test.dart
82418241
[operation] getErrorsCannotReuse
8242-
instanceMemberIdMismatch
8242+
instanceMethodIdMismatch
82438243
libraryUri: package:test/a.dart
82448244
interfaceName: A
8245-
memberName: foo
8245+
methodName: foo
82468246
expectedId: #M1
82478247
actualId: #M4
82488248
[operation] analyzeFile
@@ -8468,10 +8468,10 @@ class A {
84688468
[operation] readLibraryCycleBundle
84698469
package:test/test.dart
84708470
[operation] getErrorsCannotReuse
8471-
instanceMemberIdMismatch
8471+
instanceMethodIdMismatch
84728472
libraryUri: package:test/a.dart
84738473
interfaceName: A
8474-
memberName: foo=
8474+
methodName: foo=
84758475
expectedId: <null>
84768476
actualId: #M2
84778477
[operation] analyzeFile
@@ -9001,10 +9001,10 @@ class A {}
90019001
[operation] readLibraryCycleBundle
90029002
package:test/test.dart
90039003
[operation] getErrorsCannotReuse
9004-
instanceMemberIdMismatch
9004+
instanceMethodIdMismatch
90059005
libraryUri: package:test/a.dart
90069006
interfaceName: A
9007-
memberName: foo=
9007+
methodName: foo=
90089008
expectedId: #M1
90099009
actualId: <null>
90109010
[operation] analyzeFile
@@ -9132,10 +9132,10 @@ class A {
91329132
[operation] readLibraryCycleBundle
91339133
package:test/test.dart
91349134
[operation] getErrorsCannotReuse
9135-
instanceMemberIdMismatch
9135+
instanceMethodIdMismatch
91369136
libraryUri: package:test/a.dart
91379137
interfaceName: A
9138-
memberName: foo=
9138+
methodName: foo=
91399139
expectedId: #M1
91409140
actualId: #M4
91419141
[operation] analyzeFile
@@ -9258,10 +9258,10 @@ class B = A with M;
92589258
[operation] readLibraryCycleBundle
92599259
package:test/test.dart
92609260
[operation] getErrorsCannotReuse
9261-
instanceMemberIdMismatch
9261+
interfaceConstructorIdMismatch
92629262
libraryUri: package:test/a.dart
92639263
interfaceName: B
9264-
memberName: named
9264+
constructorName: named
92659265
expectedId: #M1
92669266
actualId: #M6
92679267
[operation] analyzeFile
@@ -10459,10 +10459,10 @@ mixin A {
1045910459
[operation] readLibraryCycleBundle
1046010460
package:test/test.dart
1046110461
[operation] getErrorsCannotReuse
10462-
instanceMemberIdMismatch
10462+
instanceMethodIdMismatch
1046310463
libraryUri: package:test/a.dart
1046410464
interfaceName: A
10465-
memberName: foo
10465+
methodName: foo
1046610466
expectedId: #M1
1046710467
actualId: #M4
1046810468
[operation] analyzeFile
@@ -11274,10 +11274,10 @@ mixin A {
1127411274
[operation] readLibraryCycleBundle
1127511275
package:test/test.dart
1127611276
[operation] getErrorsCannotReuse
11277-
instanceMemberIdMismatch
11277+
instanceMethodIdMismatch
1127811278
libraryUri: package:test/a.dart
1127911279
interfaceName: A
11280-
memberName: foo
11280+
methodName: foo
1128111281
expectedId: <null>
1128211282
actualId: #M2
1128311283
[operation] analyzeFile
@@ -11657,10 +11657,10 @@ mixin A {}
1165711657
[operation] readLibraryCycleBundle
1165811658
package:test/test.dart
1165911659
[operation] getErrorsCannotReuse
11660-
instanceMemberIdMismatch
11660+
instanceMethodIdMismatch
1166111661
libraryUri: package:test/a.dart
1166211662
interfaceName: A
11663-
memberName: foo
11663+
methodName: foo
1166411664
expectedId: #M1
1166511665
actualId: <null>
1166611666
[operation] analyzeFile
@@ -11781,10 +11781,10 @@ mixin A {
1178111781
[operation] readLibraryCycleBundle
1178211782
package:test/test.dart
1178311783
[operation] getErrorsCannotReuse
11784-
instanceMemberIdMismatch
11784+
instanceMethodIdMismatch
1178511785
libraryUri: package:test/a.dart
1178611786
interfaceName: A
11787-
memberName: foo
11787+
methodName: foo
1178811788
expectedId: #M1
1178911789
actualId: #M4
1179011790
[operation] analyzeFile
@@ -12010,10 +12010,10 @@ mixin A {
1201012010
[operation] readLibraryCycleBundle
1201112011
package:test/test.dart
1201212012
[operation] getErrorsCannotReuse
12013-
instanceMemberIdMismatch
12013+
instanceMethodIdMismatch
1201412014
libraryUri: package:test/a.dart
1201512015
interfaceName: A
12016-
memberName: foo=
12016+
methodName: foo=
1201712017
expectedId: <null>
1201812018
actualId: #M2
1201912019
[operation] analyzeFile
@@ -12267,10 +12267,10 @@ mixin A {}
1226712267
[operation] readLibraryCycleBundle
1226812268
package:test/test.dart
1226912269
[operation] getErrorsCannotReuse
12270-
instanceMemberIdMismatch
12270+
instanceMethodIdMismatch
1227112271
libraryUri: package:test/a.dart
1227212272
interfaceName: A
12273-
memberName: foo=
12273+
methodName: foo=
1227412274
expectedId: #M1
1227512275
actualId: <null>
1227612276
[operation] analyzeFile
@@ -12398,10 +12398,10 @@ mixin A {
1239812398
[operation] readLibraryCycleBundle
1239912399
package:test/test.dart
1240012400
[operation] getErrorsCannotReuse
12401-
instanceMemberIdMismatch
12401+
instanceMethodIdMismatch
1240212402
libraryUri: package:test/a.dart
1240312403
interfaceName: A
12404-
memberName: foo=
12404+
methodName: foo=
1240512405
expectedId: #M1
1240612406
actualId: #M4
1240712407
[operation] analyzeFile

pkg/analyzer/test/src/dart/analysis/result_printer.dart

+12-3
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,21 @@ class DriverEventsPrinter {
382382
case ExportLibraryMissing():
383383
// TODO(scheglov): Handle this case.
384384
throw UnimplementedError();
385-
case InstanceMemberIdMismatch():
386-
sink.writelnWithIndent('instanceMemberIdMismatch');
385+
case InstanceMethodIdMismatch():
386+
sink.writelnWithIndent('instanceMethodIdMismatch');
387387
sink.writeProperties({
388388
'libraryUri': failure.libraryUri,
389389
'interfaceName': failure.interfaceName.asString,
390-
'memberName': failure.memberName.asString,
390+
'methodName': failure.methodName.asString,
391+
'expectedId': idProvider.manifestId(failure.expectedId),
392+
'actualId': idProvider.manifestId(failure.actualId),
393+
});
394+
case InterfaceConstructorIdMismatch():
395+
sink.writelnWithIndent('interfaceConstructorIdMismatch');
396+
sink.writeProperties({
397+
'libraryUri': failure.libraryUri,
398+
'interfaceName': failure.interfaceName.asString,
399+
'constructorName': failure.constructorName.asString,
391400
'expectedId': idProvider.manifestId(failure.expectedId),
392401
'actualId': idProvider.manifestId(failure.actualId),
393402
});

0 commit comments

Comments
 (0)