-
Notifications
You must be signed in to change notification settings - Fork 107
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
Revive to the object's variableElement
if available
#713
Conversation
Variables have been tracked on DartObject since https://dart.googlesource.com/sdk/+/54b7f4b72a1701f8f9a0334c94ce6f59732bd261. This change uses the variable in the reviver if it exists. I believe the existing tests in https://github.com/dart-lang/source_gen/blob/master/source_gen/test/constants_test.dart already cover this, but lmk if you'd like any additional tests
I mean, if this changes the behavior, we should have a test that shows the behavior change/improvement...right? |
This is really just a fast-path that avoids iterating all members in the library rather than a change in behavior.. That said, |
Please add a changelog entry! |
This seems to be breaking for mockito internally @mattrberry |
We are anyways doing a breaking release, so we can possibly make this change, but need to call it out in the changelog and fix mockito |
Fwiw the issue seems to be that imports don't get added for these variables in generated mockito code. That might just be a mockito bug or something I am not sure. |
I also just looked at one case and it seems like the source_gen Revivable is correct, which would align with your thought that mockito just isn't emitting the import. I haven't worked much with mockito, but I can take a look if you aren't already |
This reverts commit ac1837f.
If you can that would be great, I only looked enough to understand mockito was the problem |
Mockito assumes that the import uri is where the object's type is defined, which isn't always true. This seems like a bug in mockito. e.g. // foo.dart
class Foo {
static final bar = Bar();
}
// bar.dart
class Bar {} With this change, we now create a |
Variables have been tracked on DartObject since https://dart.googlesource.com/sdk/+/54b7f4b72a1701f8f9a0334c94ce6f59732bd261. This change uses the variable in the reviver if it exists. I believe the existing tests in https://github.com/dart-lang/source_gen/blob/master/source_gen/test/constants_test.dart already cover this, but lmk if you'd like any additional tests
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.