Skip to content

Commit 75ef6a8

Browse files
dickermoshesrawlins
authored andcommitted
fix nits
1 parent c8d036f commit 75ef6a8

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Require dart_style >= 2.3.7, so that the current Dart language version can be
1010
passed to `DartFormatter`.
1111
* Add topics to `pubspec.yaml`.
12-
* Fix a bug where typedef-aliases in type arguments were not correctly
12+
* Fix a bug where type aliases in type arguments were not correctly
1313
resolved.
1414
* Fix a bug where record types were not correctly resolved.
1515

lib/src/builder.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,14 @@ $rawOutput
180180
return;
181181
}
182182
seenTypes.add(type);
183-
librariesWithTypes.addAll([
184-
if (type.element?.library != null) type.element!.library!,
185-
if (type.alias?.element.library != null) type.alias!.element.library,
186-
]);
183+
184+
if (type.element?.library case var library?) {
185+
librariesWithTypes.add(library);
186+
}
187+
if (type.alias?.element.library case var library?) {
188+
librariesWithTypes.add(library);
189+
}
190+
187191
type.element?.accept(typeVisitor);
188192
type.alias?.element.accept(typeVisitor);
189193
switch (type) {

test/builder/auto_mocks_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3583,8 +3583,7 @@ void main() {
35833583
expect(mocksContent, contains('implements _i2.Baz'));
35843584
});
35853585

3586-
test('when its a type parameter of function which returns another type',
3587-
() async {
3586+
test('when it\'s a function which returns any type', () async {
35883587
final mocksContent = await buildWithNonNullable({
35893588
...annotationsAsset,
35903589
'foo|lib/foo.dart': dedent(r'''
@@ -3612,14 +3611,15 @@ void main() {
36123611
expect(mocksContent, contains('class MockFoo extends _i1.Mock'));
36133612
expect(mocksContent, contains('implements _i2.Foo'));
36143613
});
3615-
test('when its a duplicate type parameter', () async {
3614+
test('when the underlying type is identical to another type alias',
3615+
() async {
36163616
final mocksContent = await buildWithNonNullable({
36173617
...annotationsAsset,
36183618
'foo|lib/foo.dart': dedent(r'''
36193619
class Bar {}
36203620
typedef BarDef = int Function();
36213621
typedef BarDef2 = int Function();
3622-
class BaseFoo<T,P> {
3622+
class BaseFoo<T, P> {
36233623
BaseFoo(this.t1, this.t2);
36243624
final T t1;
36253625
final P t2;
@@ -3707,7 +3707,7 @@ void main() {
37073707
contains('returnValue: _i3.Future<(int, {_i2.Bar bar})>.value('),
37083708
contains('bar: _FakeBar_0('))));
37093709
});
3710-
test('are supported as typedefs', () async {
3710+
test('are supported as type arguments', () async {
37113711
final mocksContent = await buildWithNonNullable({
37123712
...annotationsAsset,
37133713
'foo|lib/foo.dart': dedent(r'''
@@ -3731,7 +3731,7 @@ void main() {
37313731
expect(mocksContent, contains('class MockFoo extends _i1.Mock'));
37323732
expect(mocksContent, contains('implements _i2.Foo'));
37333733
});
3734-
test('are supported as nested typedefs', () async {
3734+
test('are supported as nested type arguments', () async {
37353735
final mocksContent = await buildWithNonNullable({
37363736
...annotationsAsset,
37373737
'foo|lib/foo.dart': dedent(r'''

0 commit comments

Comments
 (0)