Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer support for type arguments on annotations #44838

Closed
stereotype441 opened this issue Feb 2, 2021 · 5 comments
Closed

Analyzer support for type arguments on annotations #44838

stereotype441 opened this issue Feb 2, 2021 · 5 comments
Assignees
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@stereotype441
Copy link
Member

stereotype441 commented Feb 2, 2021

(Parent issue #44917)

This issue tracks the analyzer work necessary to support type arguments on annotations, for example:

@TypeHelper<int>(42, "The meaning")

For justification and additional planning details, please see:

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. type-enhancement A request for a change that isn't a bug labels Feb 2, 2021
@stereotype441 stereotype441 self-assigned this Feb 2, 2021
@srawlins srawlins added analyzer-spec Issues with the analyzer's implementation of the language spec P2 A bug or feature request we're likely to work on labels Feb 3, 2021
dart-bot pushed a commit that referenced this issue Feb 4, 2021
Bug: #44838
Change-Id: I55b8dacc571570568c1b3f101a1a4e1f517f7f6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182581
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
dart-bot pushed a commit that referenced this issue Feb 5, 2021
Currently we don't support generic metadata, but we'll be adding
support soon (dart-lang/language#1297).
When we add it, we'll still want to have tests to make sure that it's
not allowed in older language versions.

The tests we currently have to make sure it's not allowed only test
annotations occurring outside of function bodies, however the front
end code paths for handling code inside function bodies are
sufficiently different that it makes sense to test inside function
bodies too.

Bug: #44838
Change-Id: I846f2fc2e5ae090f21744ed6407b21a48a6d08ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182601
Reviewed-by: Bob Nystrom <rnystrom@google.com>
dart-bot pushed a commit that referenced this issue Feb 5, 2021
This CL updates the parser so that it allows annotations of the form:

    `@` <constructorDesignation> <argumentPart>

Where <argumentPart> can contain type arguments.  Previously this was
prohibited at parse time.

Generic annotations are still prohibited in the current language
version, but the error is now generated by the parser listener
(BodyBuilder in the case of CFE, AstBuilder in the case of analyzer);
this should open the door for future CLs to add support for generic
annotations when the `generic-metadata` experimental flag is supplied.

Bug: #44838
Change-Id: I90604f38bcb378fc798c5737e486fb26589d4d1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182668
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
dart-bot pushed a commit that referenced this issue Feb 5, 2021
Bug: #44838
Change-Id: If69cbbc13a087f0f6280da0bc7f9dbca1d3ec0ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
dart-bot pushed a commit that referenced this issue Feb 5, 2021
The update to AstCloner was made as part of
ba5064f, but it couldn't be unit
tested until now due to the lack of parser support.

Bug: #44838
Change-Id: If2fd5ce41a46c3460b5f90ba854f22ae1baef11c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182840
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
@devoncarew devoncarew added this to the March Beta Release milestone Feb 9, 2021
@scheglov scheglov assigned scheglov and unassigned stereotype441 Mar 16, 2021
@scheglov
Copy link
Contributor

@leafpetersen @eernstg Are we allowed to combine generic metadata and generic functions as type arguments? Is this valid code?

class A<T> {
  const A();
}

@A<U Function<U>()>()
void f() {}

Or with inference?

class A<T> {
  const A(T _);
}

@A(g)
void f() {}

U g<U>() => throw 0;

@eernstg
Copy link
Member

eernstg commented Mar 19, 2021

I see no reason to make that combination an error, whether inferred or written explicitly.

dart-bot pushed a commit that referenced this issue Apr 1, 2021
Change-Id: I6d22e06775d31856fc85a350892efe15208832f5
Bug: #44838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193743
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
@scheglov
Copy link
Contributor

scheglov commented Apr 2, 2021

AFAIK this is done.

@scheglov scheglov closed this as completed Apr 2, 2021
@leafpetersen
Copy link
Member

#45579

@leafpetersen leafpetersen reopened this Apr 3, 2021
@scheglov
Copy link
Contributor

scheglov commented Apr 3, 2021

#45579 was fixed.

@scheglov scheglov closed this as completed Apr 3, 2021
@eernstg eernstg added the implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) label Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. implementation Track the implementation of a specific feature (use on area-meta issue, not issues for each tool) P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants