Skip to content

Commit b421775

Browse files
Googlercopybara-github
authored andcommitted
Internal change
PiperOrigin-RevId: 550196851
1 parent afa20a8 commit b421775

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

lib/src/builder.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ class _MockTargetGatherer {
512512

513513
static Iterable<_MockTarget> _mockTargetsFromGenerateMocks(
514514
ElementAnnotation annotation, LibraryElement entryLib) {
515-
final generateMocksValue = annotation.computeConstantValue()!;
516-
final classesField = generateMocksValue.getField('classes')!;
517-
if (classesField.isNull) {
515+
final generateMocksValue = annotation.computeConstantValue();
516+
final classesField = generateMocksValue?.getField('classes');
517+
if (classesField == null || classesField.isNull) {
518518
throw InvalidMockitoAnnotationException(
519519
'The GenerateMocks "classes" argument is missing, includes an '
520520
'unknown type, or includes an extension');
@@ -548,7 +548,7 @@ class _MockTargetGatherer {
548548
fallbackGenerators: {},
549549
));
550550
}
551-
final customMocksField = generateMocksValue.getField('customMocks');
551+
final customMocksField = generateMocksValue?.getField('customMocks');
552552
if (customMocksField != null && !customMocksField.isNull) {
553553
final customMocksAsts =
554554
_customMocksAst(annotation.annotationAst)?.elements ??

test/builder/auto_mocks_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class GenerateMocks {
3030
final List<Type> classes;
3131
final List<MockSpec> customMocks;
3232
33-
const GenerateMocks(this.classes, {this.customMocks = []});
33+
const GenerateMocks(this.classes, {this.customMocks = const []});
3434
}
3535
3636
class MockSpec<T> {
37-
final Symbol mockName;
37+
final Symbol? mockName;
3838
3939
final bool returnNullOnMissingStub;
4040
@@ -43,7 +43,7 @@ class MockSpec<T> {
4343
final Map<Symbol, Function> fallbackGenerators;
4444
4545
const MockSpec({
46-
Symbol as,
46+
Symbol? as,
4747
this.returnNullOnMissingStub = false,
4848
this.unsupportedMembers = const {},
4949
this.fallbackGenerators = const {},

test/builder/custom_mocks_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GenerateNiceMocks {
3939
}
4040
4141
class MockSpec<T> {
42-
final Symbol mockName;
42+
final Symbol? mockName;
4343
4444
final List<Type> mixins;
4545

0 commit comments

Comments
 (0)