Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Issue 1723443003: First step of support for parsing and ignoring generic methods. (Closed)

Created:
4 years, 10 months ago by eernst
Modified:
4 years, 8 months ago
CC:
reviews_dartlang.org
Base URL:
https://github.com/dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

First 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+564 lines, -35 lines) Patch
M pkg/compiler/lib/src/apiimpl.dart View 1 chunk +2 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/commandline_options.dart View 1 1 chunk +1 line, -0 lines 0 comments Download
M pkg/compiler/lib/src/common/resolution.dart View 2 chunks +2 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/compiler.dart View 1 2 3 4 5 5 chunks +15 lines, -7 lines 0 comments Download
M pkg/compiler/lib/src/dart2js.dart View 1 chunk +1 line, -0 lines 0 comments Download
M pkg/compiler/lib/src/parser/class_element_parser.dart View 1 2 3 4 1 chunk +8 lines, -3 lines 0 comments Download
M pkg/compiler/lib/src/parser/diet_parser_task.dart View 1 2 3 4 2 chunks +10 lines, -4 lines 0 comments Download
M pkg/compiler/lib/src/parser/element_listener.dart View 1 chunk +13 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/parser/parser.dart View 1 2 3 4 5 15 chunks +203 lines, -2 lines 0 comments Download
M pkg/compiler/lib/src/parser/parser_task.dart View 1 2 3 4 3 chunks +10 lines, -5 lines 0 comments Download
M pkg/compiler/lib/src/parser/partial_elements.dart View 1 2 3 4 3 chunks +8 lines, -2 lines 0 comments Download
M pkg/compiler/lib/src/parser/partial_parser.dart View 1 chunk +9 lines, -3 lines 0 comments Download
M pkg/compiler/lib/src/patch_parser.dart View 1 2 3 4 5 5 chunks +18 lines, -8 lines 0 comments Download
M pkg/compiler/lib/src/serialization/modelz.dart View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
A tests/language/generic_functions_test.dart View 1 2 3 4 1 chunk +109 lines, -0 lines 0 comments Download
A tests/language/generic_functions_test.options View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A tests/language/generic_methods_test.dart View 1 2 3 4 1 chunk +110 lines, -0 lines 0 comments Download
A tests/language/generic_methods_test.options View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A tests/language/generic_sends_test.dart View 1 2 3 4 1 chunk +27 lines, -0 lines 0 comments Download
A tests/language/generic_sends_test.options View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
M tests/language/language.status View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M tests/language/language_analyzer2.status View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download

Messages

Total messages: 29 (4 generated)
eernst
Johnni and Peter: I'm not sure who's going to be back first, so I'm sending ...
4 years, 10 months ago (2016-02-22 12:00:57 UTC) #2
floitsch
LGTM with comments. Please add tests that focus on the new feature. For example, there ...
4 years, 10 months ago (2016-02-22 12:45:20 UTC) #4
floitsch
Also: wait for Johnni and/or Peter.
4 years, 10 months ago (2016-02-22 12:46:06 UTC) #5
eernst
Some extra information about the test failures I mentioned (to Florian): Running the `test-all.sh` script ...
4 years, 10 months ago (2016-02-22 15:16:57 UTC) #6
eernst
A question is embedded in the review response, search for 'added'. https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/parser/parser.dart File pkg/compiler/lib/src/parser/parser.dart (right): ...
4 years, 10 months ago (2016-02-22 18:02:52 UTC) #7
floitsch
https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/commandline_options.dart File pkg/compiler/lib/src/commandline_options.dart (right): https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/commandline_options.dart#newcode52 pkg/compiler/lib/src/commandline_options.dart:52: static const String genericMethods = '--enable-generic-methods'; drop the "enable". ...
4 years, 10 months ago (2016-02-22 18:40:27 UTC) #8
Leaf
Great to see this happening! A couple of comments. Gilad and I hashed out some ...
4 years, 10 months ago (2016-02-22 19:18:03 UTC) #10
ahe
Some of the information contained in this CL's description belongs as comments in the code, ...
4 years, 10 months ago (2016-02-23 08:05:27 UTC) #11
floitsch
https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/commandline_options.dart File pkg/compiler/lib/src/commandline_options.dart (right): https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/commandline_options.dart#newcode52 pkg/compiler/lib/src/commandline_options.dart:52: static const String genericMethods = '--enable-generic-methods'; Think about it: ...
4 years, 10 months ago (2016-02-23 10:40:48 UTC) #12
eernst
On 2016/02/23 10:40:48, floitsch wrote: > https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/commandline_options.dart > File pkg/compiler/lib/src/commandline_options.dart (right): > > https://codereview.chromium.org/1723443003/diff/1/pkg/compiler/lib/src/commandline_options.dart#newcode52 > ...
4 years, 10 months ago (2016-02-23 11:58:47 UTC) #13
eernst
Need to clarify how to create the right issues for the vm, precompiler, dart2app, and ...
4 years, 10 months ago (2016-02-23 12:40:45 UTC) #14
eernst
On 2016/02/22 19:18:03, Leaf wrote: > Great to see this happening! A couple of comments. ...
4 years, 10 months ago (2016-02-23 16:50:03 UTC) #15
eernst
On 2016/02/23 08:05:27, ahe wrote: > Some of the information contained in this CL's description ...
4 years, 10 months ago (2016-02-23 16:54:23 UTC) #16
eernst
About moving parts of the CL description into the code as comments: Any permanent software ...
4 years, 10 months ago (2016-02-24 11:02:46 UTC) #17
eernst
Will rebase this CL unto the current tip of the master branch, retest on `language`, ...
4 years, 10 months ago (2016-02-24 11:05:35 UTC) #18
floitsch
On 2016/02/24 11:05:35, eernst wrote: > Will rebase this CL unto the current tip of ...
4 years, 10 months ago (2016-02-24 14:09:09 UTC) #19
ahe
I don't think this CL should be landed yet.
4 years, 10 months ago (2016-02-24 14:13:22 UTC) #20
eernst
On 2016/02/24 14:13:22, ahe wrote: > I don't think this CL should be landed yet. ...
4 years, 10 months ago (2016-02-24 14:50:58 UTC) #21
Johnni Winther
Initial comments. https://codereview.chromium.org/1723443003/diff/60001/pkg/compiler/lib/src/compiler.dart File pkg/compiler/lib/src/compiler.dart (right): https://codereview.chromium.org/1723443003/diff/60001/pkg/compiler/lib/src/compiler.dart#newcode526 pkg/compiler/lib/src/compiler.dart:526: enableGenericMethods: enableGenericMethods), Pass [parserOptions] instead. (Also below) ...
4 years, 9 months ago (2016-02-29 10:18:45 UTC) #22
eernst
Coming back to this, I've looked at the comments I received so far and I've ...
4 years, 9 months ago (2016-03-09 16:27:13 UTC) #23
eernst
Review response https://codereview.chromium.org/1723443003/diff/60001/pkg/compiler/lib/src/compiler.dart File pkg/compiler/lib/src/compiler.dart (right): https://codereview.chromium.org/1723443003/diff/60001/pkg/compiler/lib/src/compiler.dart#newcode526 pkg/compiler/lib/src/compiler.dart:526: enableGenericMethods: enableGenericMethods), On 2016/02/29 10:18:45, Johnni Winther ...
4 years, 9 months ago (2016-03-09 16:28:13 UTC) #24
ahe
Not lgtm. Please address my concerns and/or reach out to me for details.
4 years, 9 months ago (2016-03-09 16:45:15 UTC) #25
eernst
On 2016/03/09 16:45:15, ahe wrote: > Not lgtm. Please address my concerns and/or reach out ...
4 years, 9 months ago (2016-03-09 16:50:50 UTC) #26
eernst
Peter convinced me that a recursive approach to `isValidTypeArguments` doesn't have to incur an O(n^2) ...
4 years, 9 months ago (2016-03-10 13:54:25 UTC) #27
eernst
4 years, 8 months ago (2016-04-08 11:17:37 UTC) #28
Closing this CL --- all reusable elements have been transferred to newer CL's
doing similar things one thing at a time. (So this one will never be landed).

Powered by Google App Engine
This is Rietveld 408576698