Skip to content

Commit 32683f5

Browse files
srawlinscopybara-github
authored andcommitted
Import several commits from GitHub:
* d358e24 * 8e88b5b * 85af696 PiperOrigin-RevId: 720248839
1 parent 1c48aa7 commit 32683f5

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 5.4.6
2+
3+
* When formatting a generated mocks library, use the language version of the
4+
library with the mockito annotation.
5+
16
## 5.4.5
27

38
* Ignore "must_be_immutable" warning in generated files. Mocks cannot be made

lib/src/builder.dart

+3-5
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,9 @@ class MockBuilder implements Builder {
141141
orderDirectives: true,
142142
useNullSafetySyntax: sourceLibIsNonNullable);
143143
final rawOutput = mockLibrary.accept(emitter).toString();
144-
// The source lib may be pre-null-safety because of an explicit opt-out
145-
// (`// @dart=2.9`), as opposed to living in a pre-null-safety package. To
146-
// allow for this situation, we must also add an opt-out comment here.
144+
147145
final mockLibraryContent =
148-
DartFormatter(languageVersion: DartFormatter.latestLanguageVersion)
146+
DartFormatter(languageVersion: entryLib.languageVersion.effective)
149147
.format('''
150148
// Mocks generated by Mockito $packageVersion from annotations
151149
// in ${entryLib.definingCompilationUnit.source.uri.path}.
@@ -195,7 +193,7 @@ $rawOutput
195193
interface.typeArguments.forEach(addTypesFrom);
196194
interface.allSupertypes.forEach(addTypesFrom);
197195
case final analyzer.RecordType record:
198-
record.positionalTypes.forEach(addTypesFrom);
196+
record.positionalFields.map((e) => e.type).forEach(addTypesFrom);
199197
record.namedFields.map((e) => e.type).forEach(addTypesFrom);
200198
}
201199
}

lib/src/version.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const packageVersion = '5.4.5';
1+
const packageVersion = '5.4.6';

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: mockito
2-
version: 5.4.5
2+
version: 5.4.6
33
description: >-
44
A mock framework inspired by Mockito with APIs for Fakes, Mocks,
55
behavior verification, and stubbing.
@@ -30,5 +30,5 @@ dev_dependencies:
3030
build_web_compilers: ^4.0.11
3131
http: ^1.0.0
3232
lints: ^5.1.0
33-
package_config: ^2.1.0
33+
package_config: ^2.1.1
3434
test: ^1.24.4

0 commit comments

Comments
 (0)