Commit Graph

525 Commits

Author SHA1 Message Date
Sam Rawlins 930697a158 Improve messaging of invalid yield type
Fixes https://github.com/dart-lang/sdk/issues/47379

We use a separate message for yield expressions, so that the yielded
type can be used. In checking against the yielded type, we also stop
reporting in some cases, which removes duplicate errors.

Change-Id: I2ce036086ca06d5ff32531afd4b1812f17b908ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218745
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-11-01 15:28:51 +00:00
Paul Berry ad23a8e5eb Rework error handling in message decoding.
This should make the errors much more comprehensible if there is a
formatting error in one of the `messages.yaml` files.

Change-Id: Ic2593d7b86a8a405dfdfe7ed40d2e50fa4c2c6d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-20 17:08:01 +00:00
Ahmed Ashour d041cf0478 Remove extra the, be and of
Fixes #https://github.com/dart-lang/sdk/issues/47504

TEST=No tests needed, only comments affected.

Change-Id: Ie096307b5ce314d328fea6780f396aaa226ad3b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216182
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2021-10-20 09:29:01 +00:00
Paul Berry 04c8ef2bf1 Reduce the use of <unnamed> in analyzer error messages.
Two error messages are affected:

1. When the user tries to access a static member of an extension
through an instance of a class that mentions the extension's "on"
type, and that extension is unnamed, we now report
INSTANCE_ACCESS_TO_STATIC_MEMBER_OF_UNNAMED_EXTENSION instead of
INSTANCE_ACCESS_TO_STATIC_MEMBER.  The new error message is the same
as the old one (and uses the same sharedName), but it omits the
correction message suggesting to the user that they try accessing the
static method directly via the extension name, since this advice
doesn't apply.

2. When we report AMBIGUOUS_EXTENSION_MEMBER_ACCESS, if one of the
ambiguous members comes from an unnamed extension, we now report the
unnamed extension as "unnamed extension on '$type'" rather than
referring it to as an extension named `<unnamed>`.

Change-Id: I3ca3a1ccc9399b26b083040de20db8e4f691be32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217102
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-18 19:27:18 +00:00
Paul Berry 267323de7d Remove unnecessary declaration names from error codes.
The errors HintCode.INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION and
CompileTimeErrorCode.EXTENSION_CONFLICTING_STATIC_AND_INSTANCE didn't
really need to name the enclosing declaration, since the user can
easily find the enclosing declaration from the location of the error
message.  Without this change, there are some situations where an
error message would awkwardly refer to an unnamed extension as having
the name `<unnamed>`.

Change-Id: I4ddec389f18e78167464b1b5c35556e92dd1c15f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216860
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-18 18:26:04 +00:00
Paul Berry 72daafd70c Fix correction message for CompileTimeErrorCode.INSTANCE_ACCESS_TO_STATIC_MEMBER.
Previously, it assumed that the static member was always a class; it
could also be an extension or a mixin, and the extension could be
unnamed.  This change causes extensions (named and unnamed) to be
handled properly.

Handling mixins will be more complicated (since it will require
expanding ElementKind to include mixins), so that is not addressed
right now (see https://github.com/dart-lang/sdk/issues/47452).

Change-Id: Ie01a6abfdb560d97e545d36255909da19500b3c4
Bug: https://github.com/dart-lang/sdk/issues/47452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-14 22:13:55 +00:00
Brian Wilkerson d6936a5749 Make the use of Example and Examples more consistent
I think the headings are now 'correct' in the sense that they are
singular when there's a single example and plural when there is more
than one.

In the process I noticed that we have a similar problem with 'Common
fixes' in that sometimes there's one fix and sometimes multiple. I
don't think it would read well to say 'Common fix', so I'm disinclined
to change those, but it makes me wonder whether I should have just
used 'Examples' everywhere.

Change-Id: Idbfc3354b52cf1da677db51f4c626bb3269465b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215983
Commit-Queue: Kathy Walrath <kathyw@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
2021-10-13 21:41:17 +00:00
Konstantin Shcheglov aeb6767650 Issue 47407. Move USE_OF_NATIVE_EXTENSION to CompileTimeErrorCode.
Bug: https://github.com/dart-lang/sdk/issues/47407
Change-Id: I342579ecac391ffc013cf7f05e81584996a7eea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216268
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-12 16:13:30 +00:00
Konstantin Shcheglov c3b31a94d3 Return Uint8List from summary builders.
R=brianwilkerson@google.com

Change-Id: Ib8e71d9094049129b3c4c6d3d3dcbf3f055e2864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216271
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-12 01:20:44 +00:00
Paul Berry c52a4261c0 Modify analyzer documentation handling tools to read from messages.yaml.
Previously, `pkg/analyzer/test/verify_diagnostics_test.dart` and
`pkg/analyzer/tool/diagnostics/generate.dart` extracted documentation
from the code of the analyzer error classes.  However, since this code
is generated from `messages.yaml`, it's much cleaner to just extract
the documentation directly from the YAML.

Change-Id: I7dc3eb73abbf5d72f203abbf04e43856b60d2a89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215648
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-07 13:17:13 +00:00
Paul Berry a706779df1 Refactor additional logic for analyzer error message generation.
This change moves a lot of logic into `error_code_info.dart`.  In a
follow-up CL I'll make use of this code to re-work
`verify_diagnostics_test.dart` and the code generator for the
analyzer's `diagnostics.md` file.

Change-Id: I0dca7d30a9def771f03c6a51d26335aeab1c964c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215662
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-06 16:08:49 +00:00
Paul Berry 25532307c4 Clean up code for parsing analyzer documentation and extracting code samples.
Previously this logic was duplicated in two separate locations,
`verify_diagnostics_test.dart` and the code generator for
`diagnostics.md`.  Unifying it will pave the way for a follow-up CL in
which I intend to parse the documentation directly from the
`messages.yaml` files (rather than from comments in the analyzer
classes that are generated from those files).

I've also taken this opportunity to add some more checks to the
parsing logic, so that mistakes in the documentation (e.g. misspelling
a section header) will be reported as errors rather than causing a
silent loss of functionality.

Change-Id: Icfcb52229eb94bb06bc57334e265ef4d6db299de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215580
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-05 17:29:41 +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
Paul Berry 757d179380 Update nomenclature in ErrorCode and related classes.
This change standardizes most of the analyzer to refer to problem
messages and correction messages using the names `problemMessage` and
`correctionMessage` (consistent with the naming convention used in the
analyzer and CFE `messages.yaml` files).

Change-Id: I72f078a368c65b346626f560cc721fcff4836452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215151
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-04 19:50:37 +00:00
Paul Berry 90cfd7afd0 Rename syntactic_errors.analyzer.g.dart to syntactic_errors.g.dart
Change-Id: Ibf80d44306313950c309af76122151086c7e7dc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215362
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-04 15:09:46 +00:00
Paul Berry b2c2acee09 Adjust front end nomenclature for error messages.
This change updates the classes Message, MessageCode, Template,
LocatedMessage, and FormattedMessage so that they uniformly refer to
error message text using the terminology `problemMessage` and to
correction suggestions using the terminology `correctionMessage`.
This brings them into alignment with the names we've decided to use to
unify the structure of front_end and analyzer, and makes them match
the names used in the anlayzer and front end's `messages.yaml` files.

Change-Id: Idcbb7ccfff6bb4e99ca22a3ef3c19d83880cf3c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215154
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-04 13:32:46 +00:00
Paul Berry 33f69b0ced Clean up documentation/comments handling for shared errors.
For errors that are shared between the front end and the analyzer, we
move the `documentation` and `comment` fields from
`pkg/analyzer/messages.yaml` to `pkg/front_end/messages.yaml` (where
the rest of the information about the error is).  This eliminates the
need to have any entries at all for these shared errors in the
`pkg/analyzer/messages.yaml` file, so we no longer need the boolean
flag `copyFromCfe` in this file.

This simplifies generation of analyzer error codes, so we go ahead and
take this opportuntity to remove the old `syntactic_errors.g.dart`
file, and instead code generate all the shared messages directly into
`syntactic_errors.analyzer.g.dart`.

In a follow-up CL I'll rename `syntactic_errors.analyzer.g.dart` back
to `syntactic_errors.g.dart` to reduce confusion.

Change-Id: I1e314e51c94ef595d9d6de8ba2b30e12a18382a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215155
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-04 13:03:26 +00:00
Paul Berry 67a119abe8 Update nomenclature in messages.yaml files.
Change the terms `template`/`tip` in the analyzer and front end's
`messages.yaml` files to `problemMessage`/`correctionMessage`.

Rationale: these terms were previously agreed on for unifying the
analyzer and front end, and they are currently used in the
`Diagnostic` class, which is part of the analyzer public API.
Change-Id: Ifaed92ab5176bba7b7f4c3bb915e9839520330f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215149
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-10-01 15:32:06 +00:00
Paul Berry 97255ff97e Code generate analyzer errors from the analyzer's messages.yaml file.
Change-Id: I1687acd7c777733caf93e20d703554c2a7da26cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214304
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-01 15:24:13 +00:00
Paul Berry bdbb4baea5 Create a YAML file to hold analyzer error text.
I've included both the YAML file (`messages.yaml`) and the script I
used to create it (`extract_errors_to_yaml.dart`), so that we can keep
the YAML file up to date until we finish writing logic that code
generates the analyzer errors from the YAML file.

Change-Id: Icbdcaf63a37105b666b11f7356e3fa246a8d65cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214133
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-01 13:04:39 +00:00
Paul Berry bbbd124c59 Create tables mapping CFE/analyzer error codes and indices.
Previously, these mappings were computed on the fly during generation
of syntactic_errors.g.dart.  Moving the mappings to their own data
structure makes the logic easier to re-use.

Change-Id: I1c38649b8c4aa4a42a6aa560faf67502d1c6560f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215001
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-29 18:16:30 +00:00
Konstantin Shcheglov 9826867fd0 Remove the macro prototype.
Our understanding improved, and out approach changed significantly.
So, this existing implementation is different enough to be not
very useful anymore. And it gets in my way while doing other changes.

Change-Id: If31c20a0a6f86c01a58d16390a989f77962396b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-27 23:07:53 +00:00
Paul Berry 15a028d5ec Fix SDK version associated with SDK_VERSION_GT_GT_GT_OPERATOR hint.
The `>>>` operator wasn't released until 2.14.0, not 2.3.2.

Change-Id: Ief7b7b3982109a290d229a1ede817e66bc10a6c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-27 16:17:43 +00:00
Paul Berry 7176311597 In message codegen, use json.encode to format strings.
This is more robust than just encoding the string in `r"..."` because
it allows for error messages that contain double quotes.

Change-Id: I90f698f06a8f197ad46e4bcef54deff34c23776b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214661
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-27 15:00:43 +00:00
Paul Berry 0b9fae5414 Create a data structure to represent a message loaded from YAML.
In follow-up CLs I will build on this data structure to do more
sophisticated YAML error message processing, including generation of
existing analyzer error codes from YAML.

Change-Id: If5d22e2ac3d5c123e3700f8d46c327920a941689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214076
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-27 14:52:17 +00:00
Paul Berry 94a079896b Fix error message comments to work with documentation extraction tool.
The tool `pkg/analyzer/tool/diagnostics/generate.dart` is very
particular about the format of documentation it recognizes.  This CL
corrects a few minor inconsistencies that were causing it to miss some
documentation.

Change-Id: Iac937666426e987d597323e314f60971c15371be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214421
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-27 14:11:33 +00:00
Brian Wilkerson 84c56cc846 Add more documentation for diagnostics
Change-Id: Ic135d6645a8987e9eab0e0ed406a076c81b7b4c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214507
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-26 16:48:33 +00:00
Sam Rawlins 1379c867a4 Check type parameters in const function tearoff
Fixes https://github.com/dart-lang/sdk/issues/47213

Change-Id: I6c1c7e386e64b877e1ea7d312335d924488f2306
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214134
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-22 19:36:04 +00:00
Paul Berry 3ae5055f75 Translate named placeholders to positional in generation of syntactic_errors.g.dart.
Previously, if a CFE error contained a placeholder (such as
`#string`), that wasn't converted to the equivalent analyzer
placeholder, which meant that analyzer error reporting logic needed to
know whether the error being reported came from the CFE or the
analyzer in order to report the error correctly, otherwise the
placeholder text would just show up verbatim in the analyzer output.

Change-Id: If875de3a1a80048700b0edf458377c5fc87a15d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213281
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-20 17:51:40 +00:00
Paul Berry a9873f195f Fix error message text for INVALID_MODIFIER_ON_SETTER.
This error message was previously reported by the analyzer's parser,
which presumably supplied an argument describing the modifier.  It is
now reported by the shared parser, which doesn't supply any additional
information.  As a result, the error message was showing up for the
user as "The modifier '{0}' can't be applied to the body of a setter."
(with a literal `{0}` visible to the user).

Changed the error message text to match what the CFE reports.  There's
no real need for the message to describe the modifier since the error
message location is the modifier itself.

Change-Id: I538d49c1b693fe6cfb190f584bb5c9ab5cd3cf39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213732
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-17 16:38:39 +00:00
Brian Wilkerson 9605ca2980 Fix an inconsistency in terminolgy in the documentation
Change-Id: If3e7d74af72c4d3c4e533d2c3dcd880c4f2b5bf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213622
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-16 17:10:35 +00:00
Paul Berry f8e15bda9e Add a test to make sure analyzer message generation is up to date.
This required some refactoring of the message generator so that the
same targets object can be shared between the generator and the
checker.

Change-Id: I52bdfa08b75b15667b56d0fb65c93be6ff53b845
Bug: https://github.com/dart-lang/sdk/issues/44888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213402
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-15 12:41:27 +00:00
Sam Rawlins e08ee7abec analyzer: resolve function type alias type instantiation
This code is a little weird because of how this type instantiation
works:

```
typedef Fn<T> = void Function(T);

var x = Fn<int>.foo;
var y = (Fn<int>).foo;

extension on Type {
  int get foo => 1;
}
```

`x` is illegal under any circumstance, because calling a getter on a
type instantiation can _only_ resolve to a constructor, but function
types do not have constructors. But it's nice to resolve what we can,
and what the user may have meant, and we have to represent
`Fn<int>.foo` _somehow_. So it's a property access on a TypeLiteral.

Add two new codes because it is not correct to say that `foo` is not a
getter on 'Type' because that is beside the point. The issue is that
there is no possible getter on a type-instantiated type literal of
a function type alias (nor method, nor setter).

Add lots of tests, for calling a method, a getter, and a setter on a
function type alias literal. Add tests with prefixes, bounds, too
many and too few args.

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Icdf17506a64b3382226c5e50786784130d9e3bf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213287
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-15 00:43:22 +00:00
Paul Berry 3295dda60c Add missing copyright notice to generate.dart
Change-Id: I943d0602744ff6e1841f07b79ea2bd421c646374
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-14 21:25:39 +00:00
Paul Berry 283ce865c8 Migrate pkg/analyzer/tool/messages/generate.dart to null safety
Change-Id: Ib0c80b380f895dc4d72aebbfb23f57c5e5978534
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213282
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-14 19:24:38 +00:00
Sam Rawlins 48dd9da323 Report type variables in const constructor tearoffs
This requires adding `isConst` to the ConstructorReference AST node,
which I think is appropriate, as it they can be in a constant context,
and we choose to report errors based on this state.

Change-Id: I4649c73a8bb3c2651a0e28838f0fc82574ce1622
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212603
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-08 03:41:23 +00:00
Danny Tuppeny 88a41363bc [analyzer] Support generic type aliases in available declarations
Fixes https://github.com/dart-lang/sdk/issues/46409.

Change-Id: I16fe47f52254956e58cb5f034c49e1d8fa4c22c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204403
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-08-31 17:35:04 +00:00
Konstantin Shcheglov 965af148f3 Issue 46758. LATE_FINAL_FIELD_WITH_CONST_CONSTRUCTOR.
Does not pass https://dart-review.googlesource.com/c/sdk/+/211140
yet, because requires one more fix, not reporting
CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD for const redirect constructors.

Bug: https://github.com/dart-lang/sdk/issues/46985
Bug: https://github.com/dart-lang/sdk/issues/46758
Change-Id: If6289b595545216d2d4e247214c5176a6a9d4a31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209222
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-25 15:30:47 +00:00
Sam Rawlins 419d70afb2 Fix message of RETURN_IN_GENERATOR; stop double reporting.
* This message should only be reported by the parser; the
  error raised in the analyzer was strictly duplicate.
* This message theoretically used to mention "async*" or
  "sync*" depending on the modifier that the function in
  question listed. However, listing one modifier or the
  other is a red herring, and may confuse the user; any
  function declared with one or the other is a "generator",
  and the error applies equally to a "generator" using one
  or the other modifier.

Bug: https://github.com/dart-lang/sdk/issues/43665
Change-Id: I6ef1f5c055473170e7563222f6f0a6c56a4ad5f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210801
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-24 01:43:48 +00:00
Konstantin Shcheglov 19d12d18d6 Add a tool to write all combined macro generated content.
Change-Id: I08554397016255bff82e6c420b8795999ba5990f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210427
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-18 02:30:23 +00:00
Konstantin Shcheglov 771cbb5328 Issue 46839. Remove UNCHECKED_USE_OF_NULLABLE_VALUE.
Bug: https://github.com/dart-lang/sdk/issues/46839
Change-Id: If214aab6163cd0b88a37bc04952a0cddc2bc5319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-16 16:29:14 +00:00
Sam Rawlins 7f5d1cc30d Correct some of the terminology surrounding the "default constructor."
A constructor without a name is an "unnamed" constructor. A class which
has no constructors explicitly specified implicitly has one "default
constructor". See from the spec:

> Iff no constructor is specified for a class _C_, it implicitly has a
> default constructor `C(): super() {}`, unless _C_ is the built-in
> class `Object`.

This is the singular reference in the spec to this "default
constructor." There is text which refers to the implicit
superinitializer which refers to the superclass's unnamed constructor
which must have zero arguments:

> If no superinitializer is provided, an implicit superinitializer of
> the form `super()` is added at the end of _k_'s initializer list,
> unless the enclosing class is class `Object`.

Change-Id: I3202c3923d2c561d40c2251c1b13ea4fde8bda48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208865
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-04 20:27:58 +00:00
Brian Wilkerson 878cd3a3f8 Improve the messaging around conflicting constructors
Fixes: https://github.com/dart-lang/sdk/issues/46803
Change-Id: I0435ea15cfb4c57dfb865f66d251afbe1d9459a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-08-04 17:29:47 +00:00
Konstantin Shcheglov cac96f7f8d Rename AnalysisSession.getXyz2() into getXyz().
Change-Id: Ia76aafc6a1190dcdca026097c364270389f2860a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206565
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-12 22:42:58 +00:00
Brian Wilkerson 583e37c4c9 Fix some markdown docs in diagnostic documentation
Closes: https://github.com/dart-lang/sdk/issues/46496
Change-Id: I4e7308e584bf0f26f5ff3de5f60991d7f762b747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205241
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-29 02:28:52 +00:00
Brian Wilkerson 548cba8d84 Add documentation for more diagnostics
Change-Id: Idc81811f0956a97331cd74684155da933a544b64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205066
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-28 16:11:55 +00:00
Konstantin Shcheglov f398c9f3c1 Fix pre-existing HintCode.UNNECESSARY_TYPE_CHECK_TRUE in analyzer/ and friends.
Change-Id: I1019d9c083b825a9f3418bc56ed410e0ba5501fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204085
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-06-18 16:07:26 +00:00
Brian Wilkerson 322c327ee9 Make VerifyDiagnosticsTest pass
One of the examples is now producing two diagnostics when it used to
produce a single diagnostic, so it needs to be ignored for now.

Also regenerated the diagnostic documentation, which had been missed in
a previous CL.

Change-Id: Id3c26ea86b71b11a0b5179b70175d375ec1a6ca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-10 18:40:10 +00:00
Sam Rawlins 6a798e489e Broaden text for AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH
Take this example, which includes no spreads:

```dart
f() {
  return {
    'a',
    'b': 'c',
  };
}
```

This produces the AMBIGUOUS_SET_OR_MAP_LITERAL_BOTH diagnostic.

Bug: https://github.com/dart-lang/sdk/issues/45950
Change-Id: I272519c15591d835aa6d390523a730dbc4259448
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199060
Reviewed-by: Kathy Walrath <kathyw@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-06-07 23:13:03 +00:00
Brian Wilkerson 095385c8c9 Fix the version number in the message about the availability of Never
Change-Id: I0b947240ba8b84e810fed61c238d1837ae4b8597
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202067
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-06-02 19:50:04 +00:00