Skip to content
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

Bug: Constructor invocations in platform code do not get correct default values; metadata is null #180

Open
eernstg opened this issue Jul 23, 2019 · 2 comments

Comments

@eernstg
Copy link
Collaborator

eernstg commented Jul 23, 2019

With the upcoming version 2.1.0 of reflectable the dependencies have been updated to allow for analyzer 0.37.0 (and many other dependencies have been updated as well). One of the consequences of doing this is that reflectable cannot get information from the analyzer about source code constructs (that is, AstNodes) for code in platform libraries (but note that it only affects platform libraries).

Platform libraries are the ones which are imported using 'dart:N' for some name N (e.g., 'dart:html' or 'dart:math', except 'dart:ui' which is not a platform library).

This means that reflectable cannot generate code for supporting constructor invocations with the correct default values, for constructors declared in a platform library. Instead, every optional parameter declared in a platform library is given the default value null. This means that constructor invocation via a class mirror will not faithfully mimic a regular (non-reflective) constructor invocation when optional parameters with a default value different from null are omitted.

Similarly, when querying the metadata of a declaration which is declared in a platform library, reflectable gets an error on attempts to detect the value of that metadata, and currently this is handled by pretending that the metadata does not exist.

This issue is blocked on getting a bit more flexibility from the build package (in particular, dart-lang/build#2345 is relevant, and dart-lang/build#733 as well as #172 need a similar kind of flexibility). This would allow reflectable to request a resolver which uses full libraries rather than summaries for the SDK.

@eernstg eernstg changed the title Bug: Constructor invocations in platform code do not get correct default values Bug: Constructor invocations in platform code do not get correct default values; metadata is null Jul 23, 2019
@fertrig
Copy link

fertrig commented Jul 30, 2019

Could you please confirm that this a new issue present in 2.1.0? I think this functionality was working on previous versions, like 2.0.12.

@eernstg
Copy link
Collaborator Author

eernstg commented Jul 30, 2019

Yes, it was working, it is a new issue: The new analyzer used by the build package uses summaries rather than full libraries for platform libraries, so there is no information about metadata nor about default values of parameters. (Note that platform libraries are only the ones imported using dart:..., and these problems do not occur with declarations in regular libraries.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants