Commit Graph

10861 Commits

Author SHA1 Message Date
Sam Rawlins 26bfbd4cf1 analyzer tests: Remove the WithNullSafety mixin
Two remaining test files are modified to use the TestCases structure.
In each case, the tests are unchanged, but the classes are renamed.

Additionally, each file had a *WtihNonFunctionTypes variant. Each of
these classes just specified more test cases that include some form of
"typeAlias" in the name, and can be safely merged with the null safety
test cases.

Fixes https://github.com/dart-lang/sdk/issues/44666

Bug: https://github.com/dart-lang/sdk/issues/44666
Change-Id: Id7db1038e64f8bbc12764cb558670b23427a5a86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-11 06:41:51 +00:00
Konstantin Shcheglov 79181abb70 Issue 46839. Stop using UNCHECKED_USE_OF_NULLABLE_VALUE.
Bug: https://github.com/dart-lang/sdk/issues/46839
Change-Id: Ia6a71438c265e54e83b148689e68e1e409d34cee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209500
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-11 02:56:32 +00:00
Konstantin Shcheglov 3a2e4d92a2 Remove ExperimentStatus.latestWithNullSafety
Change-Id: I0a813ce1a64f1d6201005280cf7a116deaf8da1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209581
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-11 02:37:44 +00:00
Sam Rawlins 3393591b3f Rewrite AST w/ Constructor reference w/ explicit type args
This should handle all cases of constructor reference w/ explicit type
args; there aren't too many cases:

* named and unnamed constructors
* referencing class and referencing type alias
* prefixed class names and not-prefixed
* null-aware access (weird)
* bound on type parameter of class, and on type parameter of alias

error cases:

* cascade
* wrong number of type arguments

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: If257eb561a9ad854709b6e9a7d81faa9d084d6ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209622
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-10 23:54:49 +00:00
Sam Rawlins 19fa4519bd Analyzer: Refactor and rename test classes in 18 files to use TestCases model
The diffs may look large, but only due to sorting. No tests were added,
removed, or altered.

Change-Id: Id126e9a08056f6d3f99bad32d7060d65b07e4e90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-10 18:48:50 +00:00
Sam Rawlins 2c32ff9331 Report error on function tearoff w/ type args on dynamic
From the spec:

> We do not allow dynamic explicit instantiation. If an
expression _e_ has type `dynamic` (or `Never`), then
`e.foo<int>` is a compile-time error for any name `foo`.

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: I041c3fcac77fe8edf64633a8d23dbaa89cf42f77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209623
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-10 18:36:11 +00:00
Paul Berry b266aeebc3 Move some logic from ScopedVisitor to ResolverVisitor.
Of the two classes that inherit from ScopedVisitor (ResolverVisitor
and ScopeResolverVisitor), only ResolverVisitor needs to know about
the currently enclosing class, extension, and function.  So we move
this tracking logic to the ResolverVisitor itself.  This will help
pave the way for a cleaner separation between the ResolverVisitor and
ScopeResolverVisitor.

(The ScopeResolverVisitor *does* need to know the currently enclosing
closure, so that it can detect improper break/continue statements and
so that it can detect when a local variable is mutated in a closure,
but the tracking logic needed for this is much simpler than what the
ResolverVisitor needs for the "enclosing function".  So a new
_enclosingClosure member has been added to ScopeResolverVisitor to
track this.)

Change-Id: I768c15ff4ffcabf564388f5471a6e8f88e677148
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209665
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-08-10 15:11:27 +00:00
Paul Berry 98f0e78e3c Make ScopeResolverVisitor responsible for setting break/continue targets.
This is part of a long term arc of work to consolidate all scope
lookup into a single analyzer visitor.

Change-Id: Ifc483a94173e05672b659348a3f37dd1c5b4468e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208662
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-08-10 15:11:27 +00:00
Paul Berry 8cf79c9703 Rename VariableResolverVisitor.
This is the beginning of an arc of work to move the responsibility of
all the analyzer's scope-based resolution into a single class.
VariableResolverVisitor will become that class, so accordingly it's
being renamed to ScopeResolverVisitor.

In the long term, this shift of responsibility will bring the analyzer
and the CFE into better alignment by removing scope resolution logic
from the type analysis phase (the CFE performs all scope resolution
during parsing, and then has a single visit pass to do type analysis).
This should allow analyzer and CFE logic to be more readily shared.
Also, it should improve the performance of the analyzer by allowing
Scope objects to be built up in just a single visitor pass rather than
in multiple visitor passes.

Change-Id: I037346d28de6485cac783e2bc65e0de9d3a2ada6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208661
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-10 15:11:27 +00:00
Paul Berry b53ea6cb8e Refactor scope lookup logic in preparation for consolidating scope analysis to a single visitor.
This CL refactors the scope lookup logic for simple identifiers so
that it happens in three phases:

- The actual lookup, handled by Scope.lookup

- Choosing which element is being referred to, handled by the
  LexicalLookup class

- If lexical lookup failed, falling back on implicit `this` lookup,
  handled by the ThisLookup class

In a future CL, this will allow us to consolidate the first phase,
along with all other scope-related operations, into a single visitor
so that the ResolverVisitor no longer needs to maintain scopes.  This
should simplify the analyzer's scoping logic and help prepare for
sharing more code with the CFE (since it will make the analyzer's
visitors more closely parallel the analysis phases of the CFE).

Change-Id: I0c8a2aa60bfc5a935b6060adf64e5a4504bc268f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209664
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-08-10 15:11:27 +00:00
Alexander Thomas c040c050d6 [release] Bump language version to 2.15
TEST=Standard CQ.
Change-Id: Ib50b4d23f25ea4bd074904a87068a4a8774932aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209561
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-10 13:06:53 +00:00
Konstantin Shcheglov 7ad9feb2d6 Issue 46472. Don't resolve to static Object members via dynamic.
For instance members we do this because this is the best that we
know about the result, and any successful override will be more
specific. But static members never can be invoked this way. So, we
don't do recovery for recovery.

Bug: https://github.com/dart-lang/sdk/issues/46472
Change-Id: Ifbd274011e159c3c8ae35d343603c02bb7599d8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209420
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-08-10 12:53:23 +00:00
Konstantin Shcheglov 766113bc54 Update latestSdkLanguageVersion to 2.13
Bug: https://buganizer.corp.google.com/issues/195648511
Change-Id: I7f882edaec42c6224a0863be96a41e1abd5b3329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-10 11:56:43 +00:00
Sam Rawlins d9dc244eed Analyzer: Refactor and rename test classes in 11 files to use TestCases model
The diffs may look large, but only due to sorting. No tests were added,
removed, or altered.

Change-Id: I55b591c45691319a02f272c7c6b424f0ff755d5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-09 23:30:39 +00:00
Paul Berry 8f853bc32f Unit test some corner cases of annotation resolution.
Currently, if a type parameter of a class, mixin, or extension
declaration has an annotation, that annotation is resolved in the type
parameter scope of the class, mixin, or extension declaration (meaning
that static methods are not in scope), however if scope lookup fails,
then static methods are accessible via implicit `this`.

AFAICT, this odd behavior is not spec compliant, so I've filed
https://github.com/dart-lang/language/issues/1790 to discuss the
possibilty of changing it.  However, for now I want to unit test the
behavior in order to ensure that if we make any changes to the
analyzer that affect it, the change won't go unnoticed.

Bug: https://github.com/dart-lang/language/issues/1790
Change-Id: I02df7e6e8939ecc6222085f28a6d6b7d072179c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209662
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-08-09 22:43:19 +00:00
Sam Rawlins 9b586a3da6 analyzer: add constructor references from PrefixedIdentifier
Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Ifafea6edb6c9ce7fdf1c1f092ff278738c273bb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209300
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-09 15:03:48 +00:00
Konstantin Shcheglov 04c44e8e67 Inline FeatureSetProvider.isNullSafetySdk, rename isNullSafetySdkAndLegacyLibrary.
Change-Id: I12397d77a1f77bc872f335550789322e4344d456
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-09 13:31:38 +00:00
Sam Rawlins b38ccf33e0 Combine test classes in ast_rewrite_test.dart
These two classes have the same FeatureSet, so should be combined.

Change-Id: If03e74d54ca35ed81fe532a7dc1974ecc52b6b25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-06 20:47:58 +00:00
Sam Rawlins e61ef3889e Analyzer: Refactor and rename 8 test classes in 4 files to use TestCase model
The diffs may look large, but only due to sorting. No tests were added,
removed, or altered.

Change-Id: I55246391205a8a234c05b9e1aa3ec681a178f973
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209361
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-06 20:47:49 +00:00
Paul Berry ee8ebcdc41 Clean up comments in function_expression_resolver.dart
In https://dart-review.googlesource.com/c/sdk/+/209240, I accidentally
included a stray "TODO" comment that only made sense in the context of
a previous patch set.  I also made a minor spelling error in a
comment.

This CL removes the stray TODO and fixes the spelling error.  There is
no functional change.

Change-Id: If1c600a579101cea1015d34d9833eb21a2b1a675
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-06 20:36:19 +00:00
Paul Berry 195f4c1236 Clean up hacks around resolution of documentation comments.
For some time, the visitors we use for resolution have been handling
documentation comments for most types of declarations by visiting them
*after* visiting parameters; this ensures that the parameters are in
scope at the time of visiting the documentation comment, so that the
documentation comment can refer to them.

However, a few types of declarations were done in a kludgy way:
constructor declarations, function declarations, function type
aliases, generic type aliases, and method declarations.  In some cases
we would visit the documentation comment twice, once before setting up
the scope properly (in which case the visit method would just return
early), and then again at the right time using
ResolverVisitor.safelyVisitComment (which bypassed the early return).
On other cases the visitComment method had duplicate logic for setting
up the proper scopes.

With this change, we now consistently use the approach of visiting the
documentation comment after the scopes are properly set up for it.

Change-Id: Idd27946a947040d4bad37568915bf5915bff843f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-06 19:12:28 +00:00
Konstantin Shcheglov c951b72ed5 Issue 46753. Enhance LinterContext.resolveNameInScope() to suport type parameters.
Bug: https://github.com/dart-lang/sdk/issues/46753
Change-Id: Ide53294599496cb8011e86bced0b075e389e1040
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209220
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-05 21:54:21 +00:00
Konstantin Shcheglov 39178e6b13 Issue 46206. Record redirectedConstructor even for non-const constructors.
Bug: https://github.com/dart-lang/sdk/issues/46206
Change-Id: I9a121454e382988228d62130ef2f9cad7164135a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-05 19:53:21 +00:00
Paul Berry ddfc60a41e Add a LibraryElement.accessibleExtensions getter.
This saves the ExtensionMemberResolver from having to access the
current scope in order to find out what extensions are available.
This will help prepare for a follow-up CL in which I separate the
"scope lookup" and "type analysis" phases of resolution.

As a side benefit, the analysis server no longer needs to go through
`package:analyzer/src` in order to include extensions in completion
results.

Change-Id: I6098eae219b0f7ef52b7c68f1d64c149d9e66823
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208922
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-05 17:44:42 +00:00
Sam Rawlins dcec1aca37 analyzer: Improve comments regarding "new"-named constructors.
Feedback from https://dart-review.googlesource.com/c/sdk/+/208760

Change-Id: I0cc1bd79f41307d694af37e699f237e433d1ee42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208925
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-04 23:26:53 +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 a468bd2e22 Tweaks for LinterExceptionHandler.
Boolean parameters are easier to understand when they are named.
And the word "linter" does not add much, we already know this.

Change-Id: Ib34488acd43230ac516b5fe2d3928c96dfbc6a0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-04 16:26:37 +00:00
Johnni Winther e6e25ac7b0 [cfe] Migrate remaining front_end tools
Change-Id: I75f936734a89ec5858390d96be7a5cdc4a300891
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208402
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-08-04 08:49:51 +00:00
pq 9fced4c389 check for undefined parameter references in UseResult.unless targets
Change-Id: Iaba4696c3f04efe0c104695ac51896bb81d06bb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208862
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-04 00:35:30 +00:00
pq b820538026 @UseResult verifier: check for passed "using" param
Change-Id: I5d0ececce8702c8dace87a4fbf3922fa05ba74ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208822
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-03 19:31:39 +00:00
Sam Rawlins e64597aa1b analyzer: Report duplicate unnamed and "new"-named constructors
Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: I5a737b8b227fa205e66650dd40d697e4e3ef0125
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208821
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-03 19:27:02 +00:00
Sam Rawlins 9ec112a509 analyzer: Support declaring and invoking unnamed constructor via 'new'
This adds support for both declaring an unnamed constructor with the
explicit name, "new", and support for invoking an unnamed constructor
as a named constructor named "new".

The parser will report EXPERIMENT_NOT_ENABLED if the experiment is not
enabled, as the parser takes care around the keyword, "new".

Tearoff support will be separate.

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Iaf3af333dd22337b560aa7f4e5811a4cb38b2a7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-03 03:06:41 +00:00
Paul Berry 1e0a1d9732 Move enclosingFunction getter to ScopedVisitor.
I accidentally neglected to include this change in
https://dart-review.googlesource.com/c/sdk/+/208561.

Change-Id: I9df5499a2a89d0a8889eff965027c1455befbd99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208660
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-02 17:48:40 +00:00
Paul Berry eaf75d19ff Move shouldIgnoreUndefined logic into LibraryElementImpl.
This logic was previously in LibraryScope and ScopeExtension.  It
really isn't related to scopes, though, since all it does is to look
through the library's imports and parts.  (The only use it made of
scopes was to locate the library element).

Separating this code from scopes will facilitate some other changes
I'm working on to streamline the use of scopes in the analyzer.

Change-Id: Ic45e3382628a433a96cc7ecf751b4df5d681b42a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208522
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-02 14:29:20 +00:00
Paul Berry 1d55cd7c2f Consolidate duplicate logic for tracking enclosing function.
We had logic for tracking this information in both
VariableResolverVisitor and ResolverVisitor, both of which share the
common base class ScopedVisitor.  It makes more sense to put this
logic in one place in ScopedVisitor.

Change-Id: I1cb0350039587cb67b26eda5830a8cad2d922027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208561
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-02 14:19:10 +00:00
Sam Rawlins a4afb06b21 Move InstanceCreationExpression resolution to a separate class.
This resolver may need to rewrite the AST if the TypeName resolves to be
a function reference or a constructor reference with type-instantiation.

Bug: https://github.com/dart-lang/sdk/issues/46020 https://github.com/dart-lang/sdk/issues/46721
Change-Id: Ie6a9aa3c04d739becc0c902c117a7151f9c1fcf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-01 23:02:19 +00:00
Paul Berry b13dc22338 Add an analysis option allowing linter exceptions to be propagated.
This will be used in internal builds to ensure that an exception
occuring during linting fails the build; this should help us be more
confident in the robustness of the linter code.

Change-Id: I4eaa47044b32b45433a67cc919ad047663dc771c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208141
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-30 20:05:37 +00:00
Paul Berry b7f8227c42 Remove dead code related to visitor-based lints.
In the two LibraryAnalyzer classes, the list of visitors is always
empty, so there are never any "visitor based lints" to run.  (I
suspect that all the visitor based lints were long ago converted to
use the node registry, leaving this code dead).

Removing the last remnants of the visitor based lint logic allows us
to remove the ExceptionHandlingDelegatingAstVisitor class, which in
turn allows us to move its logException method into a simpler class.
In a follow-up CL, I will expand on this class to allow its behavior
to be customized.

Change-Id: I1261a94572ea65eb220a58fb45f6d887e6497fe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208140
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-30 14:48:04 +00:00
Paul Berry f6942413e2 Make LinterVisitor's second argument optional.
This will make it possible to eliminate some references to
ExceptionHandlingDelegatingAstVisitor.logException in google3.

Change-Id: I452956827f142fd992b6b280fb560792d01a6e26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208240
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-28 15:16:04 +00:00
Sam Rawlins f4d3f801b3 Re-arrange 11 test cases to use TestCases mixin
The diffs look large but that is only the result of sorting; I did not add,
remove, or edit any test cases.

Change-Id: I2728d9c66d79561f4291c007d202eca4af01e28e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-07-27 15:54:57 +00:00
Konstantin Shcheglov e50b483976 Rename to HasMacroGenerationData.
R=brianwilkerson@google.com

Change-Id: I10c5f2900366ce2614e51c83be5f9e0138f279a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208144
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-26 23:19:46 +00:00
Konstantin Shcheglov cf5587e861 Improve macro documentation comments.
Change-Id: I1339b93d6d41566c6afc14c0e4e61fcf4e6e702a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208142
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-26 19:14:16 +00:00
pq 54ca936496 migrate Identifer.isPrivateName to string index
Fixes: https://github.com/dart-lang/sdk/issues/46724

Change-Id: I3f30f7fa8ebea798f83c40970455071c1eb9403a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-07-26 18:47:36 +00:00
Konstantin Shcheglov ca97ef0f20 Add a few data-class macros.
Mostly to excercise adding methods and constructors.

Change-Id: I378085acf047ef8b0afb6dcc75708bf1b503ee44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208025
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-07-26 17:23:28 +00:00
Sam Rawlins ef8add038f Analyzer function refs: report more disallowed instantiations
Only the following short list of elements are allowed to be type-
instantiated: top-level function, local function, instance method,
constructor, type.

Bug: https://github.com/dart-lang/sdk/issues/46233 and
Change-Id: I37e2a793b7fb25ef670152490e73b227b7c0cdac
https://github.com/dart-lang/sdk/issues/46590
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207643
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-07-26 06:49:34 +00:00
Konstantin Shcheglov c058aac7a7 Remove unused isXyz getters.
Change-Id: I404bda8b081019a8b4ec847b048666281f7b7fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208027
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-26 06:31:25 +00:00
Konstantin Shcheglov 40766bd742 Remove unused fields from Reference.
Change-Id: I0e7703f48321ccc868f8f389c8bb83f373adc33c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208026
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-24 02:07:23 +00:00
Konstantin Shcheglov 334d9264c8 Remove ElementImpl.isFromMacro
It seems that we don't need it, we have ElementMacro instead.

Change-Id: If505524e538b37c4887134ef1d36137c6fa5087e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208024
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-23 23:14:39 +00:00
Konstantin Shcheglov cf88dd2eff Move ElementImpl._languageVersion into LibraryElementImpl.
Change-Id: I9faddf46cff719e5029736ffb13e4676d0a0ba2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208023
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-23 23:10:30 +00:00