Commit 4ffea12
authored
Only generate dynamic calls when class has generic params (#1388)
Currently, a dynamic call is generated when a field is a function
(previously added [back in 2018](#498)). Without the dynamic call, [this test](https://github.com/google/built_value.dart/blob/f20857b873aa6c77395b75aa18a4c03b80f18017/end_to_end_test/test/generics_test.dart#L71-L81)
fails. The error message is:
```
00:00 +9 -1: GenericFunction can be compared [E] │
type '(int) => Null' is not a subtype of type '(dynamic) => dynamic' │
package:end_to_end_test/generics.g.dart 1726:58 _$GenericFunction.== │
test/generics_test.dart 77:63 main.<fn>.<fn>
```
In this commit, only use dynamic calls when the enclosing class has
generic parameters. This should eliminate a significant number of
dynamic call generation in cases that don't need it.
Ideally we would only generate the dynamic call when the *field* is a
function and uses type parameters from the enclosing class, but my
understanding is that is much more complex and requires deeper
integration with the analyzer.
The *.g.dart files were regenerated by locally modifying the pubspec of
end_to_end_test to use dependency_overrides to point to the local repo
(not sure if this is the right approach).
Motivation: Dynamic modules do not support dynamic calls and the
current generation of dynamic calls makes using built_value in dynamic
modules problematic. See b/481568738 for details.
Tested: Running the tests, and also doing an internal global presubmit
with this change.1 parent f20857b commit 4ffea12
5 files changed
Lines changed: 64 additions & 39 deletions
File tree
- built_value_generator
- lib/src
- test
- end_to_end_test/lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1354 | 1354 | | |
1355 | 1355 | | |
1356 | 1356 | | |
1357 | | - | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
1358 | 1361 | | |
1359 | 1362 | | |
1360 | 1363 | | |
| |||
1364 | 1367 | | |
1365 | 1368 | | |
1366 | 1369 | | |
1367 | | - | |
| 1370 | + | |
1368 | 1371 | | |
1369 | 1372 | | |
1370 | 1373 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
880 | 880 | | |
881 | 881 | | |
882 | 882 | | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
883 | 914 | | |
884 | 915 | | |
885 | 916 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments