Chromium Code Reviews
DescriptionImplements support for reflection on parameters.
During the analysis phase needed in order to see where I could store the
parameter related information, I changed many declarations from public
to private, and removed many unused classes in mirrors_unimpl.dart. Also
renamed `_reflectable` to `_reflector` a few places, for consistency.
Added `parameterMirrors` to `ReflectorData`, passed that information all
the way through to the *_reflection_data.dart files, and used that to
implement `ParameterMirrorImpl`. Extracted `VariableMirrorBase` from
`VariableMirrorImpl` as a new superclass containing the shared material
(which also means that we can have `ClassMirror` as the return type of
`MethodMirror`s `owner` and `MethodMirror` for `ParameterMirror`s `owner`,
which would otherwise mess up the return type variance of `owner`).
Strengthened the implementation in 'reflectable_implementation.dart'
such that `declarations` can only be invoked when a
`declarationsCapability` is present, as intended according to the design
document. Enforcing the same discipline in the transformer and hence
in generated code.
Added a mirror implementation for the type `dynamic` (presumably, we cannot
expect to avoid that type, and it is not possible to request support for
it using existing capabilities, and it's kind of silly to create a new
capability for a couple of odd-balls like `dynamic` (maybe `void` and
`Null` will be included for the same reason).
Decided that the set of type mirrors included should be extended will
all reachable parameter types: If we have `typeCapability` and
`declarationsCapability` then we can get `declarations` and for the
methods among them `parameters`. We should then also be able to get
a mirror for the types of those parameters, even in the case where no
other reason justifies that those `int` types should be included (e.g.,
if you have `int foo(String s)..' then `int` and `String` mirrors will
be available. This may be expensive, but requiring that all those argument
types are requsted otherwise would be very tedious. Programmers can avoid
it by omitting `typeCapability`!
Parameters whose type is a function type are not covered by this CL.
Lots of tests had to be adjusted because they violated the capability
semantics: When a test needs to call `declarations` it must also have
`declarationCapability`.
Finally, unfortunately, a number of diff chunks were created by
dartfmt, because it makes different decisions today than it did last
time those files were edited.
R=floitsch@google.com
Committed: https://github.com/dart-lang/reflectable/commit/2696c189b2b4cbcbf92a608b682761954c89424c
Patch Set 1 #
Total comments: 17
Patch Set 2 : Review response #Patch Set 3 : Merging with code from Sigurd, caused several adjustments #Messages
Total messages: 10 (1 generated)
|