File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -1367,11 +1367,11 @@ class _MockClassInfo {
1367
1367
.code;
1368
1368
} on _ReviveException catch (e) {
1369
1369
final method = parameter.enclosingElement! ;
1370
- final clazz = method.enclosingElement! ;
1371
1370
throw InvalidMockitoAnnotationException (
1372
1371
'Mockito cannot generate a valid override for method '
1373
- "'${clazz .displayName }.${method .displayName }'; parameter "
1374
- "'${parameter .displayName }' causes a problem: ${e .message }" );
1372
+ "'${mockTarget .classElement .displayName }.${method .displayName }'; "
1373
+ "parameter '${parameter .displayName }' causes a problem: "
1374
+ '${e .message }' );
1375
1375
}
1376
1376
}
1377
1377
});
Original file line number Diff line number Diff line change @@ -485,6 +485,31 @@ void main() {
485
485
);
486
486
});
487
487
488
+ test (
489
+ 'throws when given a parameter default value using a private type, and '
490
+ 'refers to the class-to-mock' , () {
491
+ _expectBuilderThrows (
492
+ assets: {
493
+ ...annotationsAsset,
494
+ ...simpleTestAsset,
495
+ 'foo|lib/foo.dart' : dedent (r'''
496
+ class FooBase {
497
+ void m([Bar a = const _Bar()]) {}
498
+ }
499
+ class Foo extends FooBase {}
500
+ class Bar {}
501
+ class _Bar implements Bar {
502
+ const _Bar();
503
+ }
504
+ ''' ),
505
+ },
506
+ message: contains (
507
+ "Mockito cannot generate a valid override for method 'Foo.m'; "
508
+ "parameter 'a' causes a problem: default value has a private type: "
509
+ 'asset:foo/lib/foo.dart#_Bar' ),
510
+ );
511
+ });
512
+
488
513
test (
489
514
'throws when given a parameter default value using a private constructor' ,
490
515
() {
You can’t perform that action at this time.
0 commit comments