DescriptionFirst step of support for parsing and ignoring generic methods.
This CL introduces support for generic method syntax: It is recognized
by the parser but no listener actions are invoked during that parsing
process. The following constructs have been added: type parameters can
be declared on function and method declarations, with the same syntax
as type parameters on class declarations, and type arguments can be
delivered in message send constructs.
Positive tests have been added, showing a range of different correct
usages. (Negative tests will be added in a follow-up CL).
Status files have been adjusted to indicate that the new tests are
`CompileTimeError`s in all cases (compilers + analyzer). If the
`--enable-generic-methods` flag is passed, `dartj2s` will not have
a compile time error.
Relative to the DEP #22 proposal, there is no support for currying
invocations (that is, we cannot use `myMethod<T,S>` as an closure
which is non-generic and which will pass the actual values of `T`
and `S` in the given context as type arguments).
The well-known syntactic conflict associated with relative expressions
is resolved in favor of generic invocations (for instance, with
`foo(m<B, C>(3))` we parse it as an invocation of `m` with type
arguments `B, C` and value argument `3`, not as two boolean
arguments passed to `foo`. It is expected that this situation is
unlikely to occur often in practice, especially because a comma or
')' will delimit the expression where we have `3` in the example,
which means that it won't need to be wrapped in parentheses. Of
course, the work-around `(C>(3))` is available if it should still
occur.
Neither the proposal in DEP #22 nor this CL adds any support for type
parameterization of literal functions (i.e., expressions like
`(x) => x`).
Patch Set 1 #
Total comments: 31
Patch Set 2 : Review response #Patch Set 3 : Corrected several typos in generic method tests #Patch Set 4 : Moved text from description to dartdoc #
Total comments: 10
Patch Set 5 : Response to Johnni's review #Patch Set 6 : Fixes bug with nested type arguments #Messages
Total messages: 29 (4 generated)
|