DescriptionAdded `dynamicReflected..Type`, corrected type expressions.
Added methods `dynamicReflectedType` and `hasDynamicReflectedType` to
class mirrors and type annotation related mirrors (variable, parameter,
and method mirrors), returning the fully dynamic instantiation of the
given [Type] object (e.g., `List` rather than `List<String>`).
Added a new public class `TypeValue` to 'mirrors.dart', such that we
can use expressions like `const TypeValue<List<int>>().type`; this is
in fact convenient in test code as well, and presumably in client code.
Corrected the code that produces type expressions for various things
(esp. values returned by `dynamicReflectedType`) such that it includes
type arguments and uses `TypeValue` when needed.
It is not easy to cover generic types in both pre- and post-transform
code, and the features around reflected types have brought up new
issues: In pre-transform code we cannot obtain `List` from a given
`List<T>` for some `T`, so `dynamicReflectedType` cannot be
implemented in all cases; but since `hasDynamicReflectedType` returns
false in these cases, users can still write reliable code. Similarly,
`reflectedType` cannot be implemented in cases like `List<E>` used
as a type annotation in the class `List`: We do not have the required
primitives to look up `E` in a given list, so we cannot produce a
class mirror and then a variable/parameter mirror that holds the
[Type] value for `E`, so `hasReflectedType` must return false here.
This means that client code must in general test with the `has..`
methods (which was obvious anyway, even if they didn't always do it)
and the `has..` methods may not return the same value in pre- and
post-transform code, which is a new kind of incompatibility.
However, it is a worse kind of incompatibility if pre-transform code
returns `List<String>` and post-transform code returns `List`, and
the behavior changes because an `==` test with `List<String>` now
fails after transformation.
Rewrote the functions named `_typeCode` and similar names
extensively to support these things.
Added a new test for `{has,}dynamicReflectedCode`.
R=sigurdm@google.com
Committed: https://github.com/dart-lang/reflectable/commit/10da7e398ce439314dacfb276e2a58ecbabce5b4
Patch Set 1 #
Total comments: 10
Patch Set 2 : Review response. #Messages
Total messages: 6 (2 generated)
|