-
Notifications
You must be signed in to change notification settings - Fork 166
Fix code generation error on nested generic bounded type arguments #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix code generation error on nested generic bounded type arguments #659
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some feedback on your code, but generally I'd like to hear from the analyzer team first.
@@ -1,3 +1,7 @@ | |||
## 5.4.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 5.4.3-wip
@@ -1,5 +1,5 @@ | |||
name: mockito | |||
version: 5.4.2 | |||
version: 5.4.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-wip
@@ -2051,7 +2051,20 @@ class _MockClassInfo { | |||
|
|||
T _withTypeParameters<T>(Iterable<TypeParameterElement> typeParameters, | |||
T Function(Iterable<TypeReference>, Iterable<TypeReference>) body) { | |||
final typeVars = {for (final t in typeParameters) t: _newTypeVar(t)}; | |||
final Map<TypeParameterElement, String> typeVars = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I wrote on the bug, I think it would be more logical to fix the equality on the analyzer side, if possible. Then, this won't be needed.
But even as a workaround, it has a few problems:
- It won't catch cases with more than one level of wrapping, like
T extends Foo<Bar<T>>
. - It will create a wrong mapping for other type variables appearing in the bound, like
class C<T> { X m<X extends Iterable<T>>() => []; }
@@ -1843,6 +1843,32 @@ void main() { | |||
expect(mocksContent, contains('Iterable<X1> m1<X1>(X1 Function(X)? f)')); | |||
expect(mocksContent, contains('Iterable<X1?> m2<X1>(X1 Function(X)? f)')); | |||
}); | |||
|
|||
test('We preserve nested generic bounded type arguments', () async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the test! Could you please try adding test cases to cover the items in my comment above? Thanks!
Closing this in favor of #671 |
Fixes #658 code generation error on nested generic bounded type arguments.
Contribution guidelines:
dart format
.Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.