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

Issue 1863053003: Adds support for --generic-method-syntax (Closed)

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

Description

Adds support for --generic-method-syntax This CL adds support for parsing and ignoring declarations of type parameters on methods and functions, and passing type arguments to method and function invocations. The type parameters thus declared do not get a representation during static analysis, so any usage will cause warnings about undefined types; hence, this CL transforms usage of generic methods from syntax errors to static warnings. A followup CL will eliminate the static warnings. R=johnniwinther@google.com Committed: https://github.com/dart-lang/sdk/commit/440b17901ef07ee68ec911f0f13c9bcc72857c18

Patch Set 1 #

Total comments: 4

Patch Set 2 : Added support for parsing generic methods (buggy, will upload again when fixed) #

Total comments: 29

Patch Set 3 : Review response #

Patch Set 4 : #

Total comments: 2

Patch Set 5 : Review response 2 (braces) #

Patch Set 6 : Rebased up to current github master #

Unified diffs Side-by-side diffs Delta from patch set Stats (+136 lines, -4 lines) Patch
M pkg/compiler/lib/src/commandline_options.dart View 1 chunk +1 line, -0 lines 0 comments Download
M pkg/compiler/lib/src/dart2js.dart View 1 2 3 4 5 1 chunk +1 line, -0 lines 0 comments Download
M pkg/compiler/lib/src/options.dart View 6 chunks +13 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/parser/element_listener.dart View 1 2 3 4 5 2 chunks +2 lines, -1 line 0 comments Download
M pkg/compiler/lib/src/parser/node_listener.dart View 1 2 3 4 5 4 chunks +4 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/parser/parser.dart View 1 2 3 4 5 12 chunks +113 lines, -3 lines 0 comments Download
M tests/compiler/dart2js/backend_dart/dart_printer_test.dart View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M tests/compiler/dart2js/options_helper.dart View 1 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 24 (4 generated)
eernst
First patch just adds support for the --generic-method-syntax option, uploaded separately for better readability. Next ...
4 years, 8 months ago (2016-04-06 11:55:44 UTC) #2
Johnni Winther
lgtm https://codereview.chromium.org/1863053003/diff/1/tests/language/generic_functions_test.options File tests/language/generic_functions_test.options (right): https://codereview.chromium.org/1863053003/diff/1/tests/language/generic_functions_test.options#newcode3 tests/language/generic_functions_test.options:3: enableGenericMethodSyntax: true Is the 'enableGenericMethods' not currently supported ...
4 years, 8 months ago (2016-04-06 12:34:58 UTC) #3
eernst
Early upload (still buggy), to ensure Peter gets an opportunity to respond before his vacation. ...
4 years, 8 months ago (2016-04-08 08:31:34 UTC) #5
ahe
I've looked at the code in parser directory. I don't think it's great to resolve ...
4 years, 8 months ago (2016-04-08 09:53:33 UTC) #6
eernst
On 2016/04/08 09:53:33, ahe wrote: > I've looked at the code in parser directory. I ...
4 years, 8 months ago (2016-04-08 11:59:26 UTC) #7
ahe
On 2016/04/08 11:59:26, eernst wrote: > On 2016/04/08 09:53:33, ahe wrote: > > I've looked ...
4 years, 8 months ago (2016-04-08 12:04:56 UTC) #8
eernst
On 2016/04/08 12:04:56, ahe wrote: > On 2016/04/08 11:59:26, eernst wrote: > > On 2016/04/08 ...
4 years, 8 months ago (2016-04-08 13:29:05 UTC) #9
eernst
On 2016/04/08 13:29:05, eernst wrote: > On 2016/04/08 12:04:56, ahe wrote: > > On 2016/04/08 ...
4 years, 8 months ago (2016-04-08 13:31:39 UTC) #10
eernst
PTAL, remaining issues: Having or not having a field `enableGenericMethodSyntax`, and merging or not merging ...
4 years, 8 months ago (2016-04-08 17:07:11 UTC) #11
eernst
Response to irl discussion. I'm currently running the longer test series (will finish in about ...
4 years, 8 months ago (2016-04-11 10:04:40 UTC) #12
floitsch
https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/parser/parser.dart File pkg/compiler/lib/src/parser/parser.dart (right): https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/parser/parser.dart#newcode607 pkg/compiler/lib/src/parser/parser.dart:607: bool isValidTypeArguments(Token token) { On 2016/04/08 17:07:10, eernst wrote: ...
4 years, 8 months ago (2016-04-11 11:00:14 UTC) #14
eernst
On 2016/04/11 11:00:14, floitsch wrote: > https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/parser/parser.dart > File pkg/compiler/lib/src/parser/parser.dart (right): > > https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/parser/parser.dart#newcode607 > ...
4 years, 8 months ago (2016-04-11 12:08:50 UTC) #15
eernst
At this point all test runs are complete, with no failures.
4 years, 8 months ago (2016-04-11 12:10:26 UTC) #16
Johnni Winther
lgtm https://codereview.chromium.org/1863053003/diff/60001/pkg/compiler/lib/src/parser/parser.dart File pkg/compiler/lib/src/parser/parser.dart (right): https://codereview.chromium.org/1863053003/diff/60001/pkg/compiler/lib/src/parser/parser.dart#newcode552 pkg/compiler/lib/src/parser/parser.dart:552: !identical(endToken.next.kind, OPEN_PAREN_TOKEN)) return null; Nit: Add braces arround ...
4 years, 8 months ago (2016-04-11 12:41:00 UTC) #17
eernst
Review response 2 https://codereview.chromium.org/1863053003/diff/60001/pkg/compiler/lib/src/parser/parser.dart File pkg/compiler/lib/src/parser/parser.dart (right): https://codereview.chromium.org/1863053003/diff/60001/pkg/compiler/lib/src/parser/parser.dart#newcode552 pkg/compiler/lib/src/parser/parser.dart:552: !identical(endToken.next.kind, OPEN_PAREN_TOKEN)) return null; On 2016/04/11 ...
4 years, 8 months ago (2016-04-11 12:55:31 UTC) #18
floitsch
On 2016/04/11 12:08:50, eernst wrote: > On 2016/04/11 11:00:14, floitsch wrote: > > > https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/parser/parser.dart ...
4 years, 8 months ago (2016-04-11 13:36:16 UTC) #19
eernst
Rebased to current master on github. Includes many changes (apparently, `dartfmt` was run on all ...
4 years, 8 months ago (2016-04-11 13:58:07 UTC) #20
eernst
Committed patchset #6 (id:100001) manually as 440b17901ef07ee68ec911f0f13c9bcc72857c18 (presubmit successful).
4 years, 8 months ago (2016-04-11 13:58:50 UTC) #22
eernst
On 2016/04/11 13:36:16, floitsch wrote: > On 2016/04/11 12:08:50, eernst wrote: > > On 2016/04/11 ...
4 years, 8 months ago (2016-04-11 15:00:12 UTC) #23
Leaf
4 years, 8 months ago (2016-04-18 20:45:57 UTC) #24
Message was sent while issue was closed.
On 2016/04/11 15:00:12, eernst wrote:
> On 2016/04/11 13:36:16, floitsch wrote:
> > On 2016/04/11 12:08:50, eernst wrote:
> > > On 2016/04/11 11:00:14, floitsch wrote:
> > > >
> > >
> >
>
https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/pa...
> > > > File pkg/compiler/lib/src/parser/parser.dart (right):
> > > > 
> > > >
> > >
> >
>
https://codereview.chromium.org/1863053003/diff/20001/pkg/compiler/lib/src/pa...
> > > > pkg/compiler/lib/src/parser/parser.dart:607: bool
> isValidTypeArguments(Token
> > > > token) {
> > > > On 2016/04/08 17:07:10, eernst wrote:
> > > > > On 2016/04/08 09:53:32, ahe wrote:
> > > > > > Rename to "isValidMethodTypeArguments" to signal that a trailing
> > > parenthesis
> > > > > is
> > > > > > required?
> > > > > 
> > > > > Makes sense, done. (This deviates from the naming of parsing methods
> after
> > > the
> > > > > grammar non-terminals---but we're beyond that anyway, because of the
> > > trailing
> > > > > '(').
> > > > >  
> > > > > > Can I assume that you can't "curry" type arguments as part of a
> tear-off
> > > > > > operation? That is, this doesn't work (assuming m is a generic
> method):
> > > > > > 
> > > > > > var f = m<a, b>;
> > > > > > f();
> > > > > 
> > > > > Right, Florian did not want to support that, and Leaf seems to be
> > relatively
> > > > > willing to leave out the curried construct (a rather
> > > > > short lambda can be used as a work-around).
> > > > 
> > > > Fwiw, this CL only adds syntactic support. The semantic meaning is
> > > independent,
> > > > and both options are still open (although I would like to avoid
currying).
> > > 
> > > Do you want to see whether it would work from a syntactic point of view,
in
> an
> > > additional CL? I'm not sure which extra ambiguities it would create, but
> > > surely the parser needs to be adjusted to allow for the curried form.
> > 
> > My mistake. Yes: I don't want to support "bound" tear-offs. Maybe we will
have
> > to add them, but for now I would rather not add the additional complexity. I
> > have already seen code that would benefit from it, so I might eventually
> change
> > my mind, though.
> 
> OK, so I won't look into parsing it now.

I'm not strongly dug in on these, but they do allow some code to be written with
less clutter.  
How much this matters depends a little on other choices we make.  A place this
sometimes 
comes up is when I have a function f which expects an (int -> int) as an
argument, and I happen
to have a (g : <T>(T) -> T) handy that I'd like to use.  This isn't that
uncommon, and it's a bit 
unpleasant to always have to write f((x) => g(x)) (assuming best case
inference).  If we allow 
inference to fill in instantiations, (or if we get a little fancy with
subtyping) then we can just 
support f(g).  At that point though, it's a little surprising that inference can
generate a 
"bound" tear-off, but you can't do it by hand.

Powered by Google App Engine
This is Rietveld 408576698