Skip to content

Commit

Permalink
fix nits
Browse files Browse the repository at this point in the history
dickermoshe authored and srawlins committed Dec 4, 2024
1 parent c8d036f commit 75ef6a8
Showing 3 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@
* Require dart_style >= 2.3.7, so that the current Dart language version can be
passed to `DartFormatter`.
* Add topics to `pubspec.yaml`.
* Fix a bug where typedef-aliases in type arguments were not correctly
* Fix a bug where type aliases in type arguments were not correctly
resolved.
* Fix a bug where record types were not correctly resolved.

12 changes: 8 additions & 4 deletions lib/src/builder.dart
Original file line number Diff line number Diff line change
@@ -180,10 +180,14 @@ $rawOutput
return;
}
seenTypes.add(type);
librariesWithTypes.addAll([
if (type.element?.library != null) type.element!.library!,
if (type.alias?.element.library != null) type.alias!.element.library,
]);

if (type.element?.library case var library?) {
librariesWithTypes.add(library);
}
if (type.alias?.element.library case var library?) {
librariesWithTypes.add(library);
}

type.element?.accept(typeVisitor);
type.alias?.element.accept(typeVisitor);
switch (type) {
12 changes: 6 additions & 6 deletions test/builder/auto_mocks_test.dart
Original file line number Diff line number Diff line change
@@ -3583,8 +3583,7 @@ void main() {
expect(mocksContent, contains('implements _i2.Baz'));
});

test('when its a type parameter of function which returns another type',
() async {
test('when it\'s a function which returns any type', () async {
final mocksContent = await buildWithNonNullable({
...annotationsAsset,
'foo|lib/foo.dart': dedent(r'''
@@ -3612,14 +3611,15 @@ void main() {
expect(mocksContent, contains('class MockFoo extends _i1.Mock'));
expect(mocksContent, contains('implements _i2.Foo'));
});
test('when its a duplicate type parameter', () async {
test('when the underlying type is identical to another type alias',
() async {
final mocksContent = await buildWithNonNullable({
...annotationsAsset,
'foo|lib/foo.dart': dedent(r'''
class Bar {}
typedef BarDef = int Function();
typedef BarDef2 = int Function();
class BaseFoo<T,P> {
class BaseFoo<T, P> {
BaseFoo(this.t1, this.t2);
final T t1;
final P t2;
@@ -3707,7 +3707,7 @@ void main() {
contains('returnValue: _i3.Future<(int, {_i2.Bar bar})>.value('),
contains('bar: _FakeBar_0('))));
});
test('are supported as typedefs', () async {
test('are supported as type arguments', () async {
final mocksContent = await buildWithNonNullable({
...annotationsAsset,
'foo|lib/foo.dart': dedent(r'''
@@ -3731,7 +3731,7 @@ void main() {
expect(mocksContent, contains('class MockFoo extends _i1.Mock'));
expect(mocksContent, contains('implements _i2.Foo'));
});
test('are supported as nested typedefs', () async {
test('are supported as nested type arguments', () async {
final mocksContent = await buildWithNonNullable({
...annotationsAsset,
'foo|lib/foo.dart': dedent(r'''

0 comments on commit 75ef6a8

Please sign in to comment.