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

LibraryMirror.declarations should include type aliases #165

Open
eernstg opened this issue Feb 20, 2019 · 0 comments
Open

LibraryMirror.declarations should include type aliases #165

eernstg opened this issue Feb 20, 2019 · 0 comments

Comments

@eernstg
Copy link
Collaborator

eernstg commented Feb 20, 2019

Cf. library_declarations_test.dart.

Obtain a LibraryMirror for a library that contains some type alias declarations and inspect its declarations: There are no entries for the type aliases.

In a lot of ways, reflectable does not support reflection on function objects (because the underlying primitives that we would have to have in order to be able to support them do not exist). But it would certainly be possible to create some TypedefMirrors and allow them to return the reflectedType, such that we could get the name and compare for equality. However, even equality is currently blocked:

Cf. dart-lang/sdk#32782: The specified equality for function types and type aliases denoting function types (which should use operator ==, which should test for being "the same underlying type, i.e., looking up the denotation of a given type alias") has not yet, as of Feb 2019, been implemented by the common front end (nor by the vm, dart2js, etc; though I believe that dartdevc has it).

This means that we cannot compare some function types, because they would be expected to be obtained via type aliases in some cases, and to be declared "inline" (using syntax like int Function()) in other cases. So we can't provide a reasonable level of support for the type aliases before the basic equality test works. Hence 'blocked'.

Nevertheless, we could already implement the ability to look up the type aliases in the declarations, and we could let the implementation return the current reified type, even though it fails to have a correct operator ==, and then "it would work" as long as the code that we're reflecting on makes the choice to declare any given function type (that we will reflect upon) using a type alias, and then using that type alias everywhere that function type is used. This is slightly better than nothing (maybe ;-), and, notably: It will "just start working" when the equality issue has been fixed.

@eernstg eernstg changed the title LibraryMirror.declarations omits type aliases LibraryMirror.declarations should include type aliases Feb 20, 2019
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

1 participant