-
Notifications
You must be signed in to change notification settings - Fork 172
Fix wrong import for method parameters with default value factories #460
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
Conversation
|
I like the idea here, but I think that the parameter element is not sufficient to choosing the right element to reference. For example, here is a test (that you can insert into auto_mocks_test.dart) which does not pass with this fix: test(
'matches parameter default values constructed from a const factory '
'constructor2', () async {
var mocksContent = await buildWithNonNullable({
...annotationsAsset,
...simpleTestAsset,
'foo|lib/foo.dart': '''
import 'baz.dart';
class Foo {
void m([Bar a = const Baz.named()]) {}
}
class Bar {
const Bar();
}
''',
'foo|lib/baz.dart': '''
import 'foo.dart';
import 'quux.dart';
class Baz implements Bar {
const factory Baz.named() = Quux;
}
''',
'foo|lib/quux.dart': '''
import 'baz.dart';
class Quux implements Baz {
const Quux();
}
''',
});
expect(mocksContent,
contains('void m([_i2.Bar? a = const _i3.Baz.named()]) =>'));
});The idea is:
I think the fix needs to be made in source_gen. |
|
Yea I didn't think of 3 levels/interface. The information is just not available at that point. I am not sure it would be correct for I still think the workaround via the |
srawlins
left a comment
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.
One comment
|
Would you mind rebasing once as well? Thanks! |
* add tests * gitignore build folder and generated mock test files
6675aff to
d0dacca
Compare
|
I think your code became unformatted with the sync. |
d0dacca to
51b5d26
Compare
|
Thanks much! I think this is definitely an improvement (especially with the real world example). |
Fixes #459