-
Notifications
You must be signed in to change notification settings - Fork 205
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
Macros: Consider doing inference for fields when possible #2154
Comments
This is also related to #2151 |
FWIW, the analyzer always links libraries cycle by cycle, so dependencies are always fully linked when we start a new library cycle, including any inferred typed. |
Good to know - that was our assumption. I believe the CFE also works this way but it would be good for @johnniwinther to confirm. Given that we are adding some asynchronous behavior to compiling a library I do worry a little bit that compilers might want to change that model, and this change would not allow them to. In a fully synchronous compiler there is no downside to doing it that way but in an asynchronous one you might want to do some other work while waiting on a macro to run (this could also reduce the overhead of macros in general). |
I think we already require that all phases of macros have run on dependencies outside of the current library cycle, because those dependencies may also contain macro declarations that need to be fully compiled so that the current library can apply them. So as far as I can tell, this requirement shouldn't be any more stringent than what we already expect. |
It just has potential impacts for the parallelism of the build. While for a macro dependency yes the macros would be ran to completion, for other dependencies they don't have to be. So you could get some parallelism if you wanted to today. Requiring it removes that possibility. |
We discussed this in our weekly meeting today, and at least for now are going to explore the following solution:
Note that the Code api will need to be slightly adjusted to allow for these instances, currently it does not accept type annotations directly at all. |
Bug: dart-lang/language#2154 Change-Id: Ie48d308a822798da22ea38954774e393f81e2e2a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237740 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jake Macdonald <jakemac@google.com>
…fer real types from OmittedTypeAnnotations. Bug:dart-lang/language#2154 Change-Id: I00484ddbd09a3c2371b96e540b9926144d80c832 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237844 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jake Macdonald <jakemac@google.com>
Currently we say that no inference is done until after macros are completed - this is largely because we may have incomplete or non-existent bodies during macro compilation.
Today we were discussing some potential failure modes of this approach. In particular, it means that it would be possible for a library to break its downstream users by adding or removing a type annotation from a field (or return type of a method), whose type is inferred. In general this should not be a breaking change, but it will be with macros since the type will now be invisible to the macros.
Here are some random ideas that could help, in some combination:
dynamic
unless otherwise specified.The text was updated successfully, but these errors were encountered: