Commit graph

11 commits

Author SHA1 Message Date
Johnni Winther dd3fbffac7 [cfe,analyzer] Support new as identifier in metadata
The parser didn't support 'new' as identifier in this context.

The CL also adds the reporting of tear-offs as metadata for the CFE.
This was already handled by the analyzer.

Change-Id: I7ab5868fa83e5f216d0e7be7ae9cec4a2c865e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364480
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-04-26 14:00:04 +00:00
Kallen Tu af24f1d61a [analyzer] Report more specific diagnostic codes instead of INVALID_CONSTANT.
Add a more specific, but for general use, diagnostic for when the evaluator encounters a type parameter. The errors should match more closely to the CFE errors now.

This CL also tidies up some other areas like `_evaluatePropertyAccess` and produces a better error than `INVALID_CONSTANT` when you try to access something that's not String.length.

Change-Id: I4780e6e52049887a0ee44cdf046968f332527079
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322364
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-08-29 22:36:02 +00:00
Lasse R.H. Nielsen 5642199dd0 Remove uses of : as default value separator in some tests/ directories.
Change-Id: I35bb926e53e92fd02e264fb5b14feadf063fb8db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257961
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-09-07 14:49:17 +00:00
Johnni Winther cf1591f935 [cfe] Refactor detection of instance type variable access in static context
NamedTypeBuilder is now created with a state that determines whether it
can validly be resolved to an instance type variable.

Change-Id: I1e7f5f8e05a5f68ec18a063476b6cda291a1aca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214643
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 11:58:04 +00:00
Johnni Winther b3af778a38 [cfe] Add UnresolvedKind for fine grained unresolved reporting
- including tests for issues 46719 and 46887

Change-Id: I601fcfcb956e059f502cbece29fb2a6a00f68846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210464
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-08-25 09:51:54 +00:00
Paul Berry f5a3bce734 Fix scope resolution of metadata on type parameters
Previously, when encountering identifiers in metadata on a class's
type parameter, the analyzer would resolve them using the type
parameter scope, but then fall back on using implicit `this`.  The CFE
would resolve them using the class body scope.  In both cases, the end
result was that the annotation could refer to static class members.

This change brings the behavior of both the analyzer and the CFE in
line with the spec, by preventing the use of implicit `this` in these
annotations, and resolving them in the type parameter scope.

This is not expected to break any code in practice, because
annotations on type parameters are rare, as are annotations referring
to static class members, and the overlap between these two should be
negligibly small.

Fixes https://github.com/dart-lang/language/issues/1790.

Bug: https://github.com/dart-lang/language/issues/1790
Change-Id: Ibe5a421e04a53d29074a8b1509e1390658ed72e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210040
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-17 15:17:02 +00:00
Erik Ernst 083dd87675 Add test of function types with metadata
This CL extends language/metadata/metadata_location_test.dart with a
couple of extra test cases, covering the situation where the metadata
occurs on a type paramater or value parameter of a function type.

Change-Id: I9b225e8c3d72aa5ddd8893526e65ab4d1b5ab2a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187922
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2021-02-26 17:24:07 +00:00
Erik Ernst 6e98c9048c Add tests for using built-in identifier id in metadata @id
Change-Id: I51105e637b4d0bb0be897c5eba3554ff436d9472
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174645
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2020-12-02 11:16:37 +00:00
Erik Ernst a917cae88c Add further cases to metadata test
Adding static methods/getters/setters to class/mixin/extension,
instance getters/setters/operators to mixin/extension, new-syntax
type alias.

Change-Id: I4e3f168d8db9c5f168b138c847bccf948c05c567
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168080
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2020-10-19 16:10:08 +00:00
Erik Ernst 016ebdd03a Add tests for metadata in all locations, cf. grammar
Change-Id: Ibaa2bcd014257c6ec7c756d352e55d48f8a4a902
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167801
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2020-10-16 08:19:42 +00:00
Robert Nystrom 9d6fd6e25d Migrate language_2/metadata to NNBD.
Change-Id: I0243e6112ea3dc31e69a2c1395e08575ab5cb276
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149561
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-06-02 16:45:26 +00:00