Commit Graph

438 Commits

Author SHA1 Message Date
Konstantin Shcheglov a0227f5902 Issue 44063. Report IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE hint.
Bug: https://github.com/dart-lang/sdk/issues/44063
Change-Id: I69c6f84da9a9c928e177507cedb30e06a561f3f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-09 19:42:08 +00:00
Sam Rawlins c6e4d6bcc8 Analyzer: new Hint: NULL_CHECK_ALWAYS_FAILS
This Hint reports when an expression of type Null is null-checked with `!`.
This check will always fail at runtime.

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

Change-Id: I6e2eac4f7b7720a6b9a1c02066470eb039aa9010
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170122
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-03 17:20:14 +00:00
Brian Wilkerson 2ab3ebad9d Remove a duplicated error code
The parser produces this diagnostic, so analyzer doesn't need to.

Change-Id: I39e2ade681e5580b6ca5493a334d87d66f51e1ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170041
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-11-02 05:06:02 +00:00
pq e5dfd38404 check for invalid git and path deps in publishable packages
Fixes: https://github.com/dart-lang/sdk/issues/43930

Change-Id: Ia1e7899cf04644387f2686e997e338baa197dac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169246
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2020-10-28 20:32:50 +00:00
Brian Wilkerson 35ce26e0db Validate ignore comments
This adds checks for three cases:
- error codes for diagnostics that are not being produced,
- error codes that can't be ignored (with a severity of error), and
- error codes that are already being ignored.

I originally also checked for names that are not defined as error codes
(which turned up at least one valid issue in the Flutter repo), but we
don't have a list of all valid names against which to compare because
plugins can add new diagnostics.

It should be noted that, as written, these diagnostics can't be ignored,
despite being hints. The reason is as follows: in order to detect
diagnostics that are not being produced, these checks need to have a
list of the diagnostics that _are_ produced. If an ignore comment
attempted to ignore one of these hints, this validation would occur
before the hint had been generated, so that comment would in turn appear
to be unnecessary.

If we need them to be ignorable, then we can special case them so that
they are never reported as being unnecessary.

And after running this over the Flutter repo I commented out two of the
three codes because there are violations. Many of the violations are
valid and need to be cleaned up. Some are the result of "ignore" being
used for other purposes. The Flutter team has said that we can replace
their use of "ignore" in order to enable these hints, but I don't have
time to do that right now and I'd like to get this landed before it bit
rots again.

Change-Id: I1704105621bef5a5c49202267c99aa1d950a26a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156402
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-18 16:53:06 +00:00
Brian Wilkerson 51b8dfb6fd Remove the unreported access_private_enum_field diagnistic
If this diagnostic needs to be generated, then I can create an issue to
track that work, but I think we handle it by not defining the private
fields in our models, which means the issue is reported as an undefined
getter.

Change-Id: I8d220adf0d11b2c65f8953eec57a87f86f520d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-10-14 19:36:43 +00:00
Konstantin Shcheglov 132e2307e7 Report MAIN_FIRST_POSITIONAL_PARAMETER_TYPE
Bug: https://github.com/dart-lang/sdk/issues/43555
Change-Id: Ieacc710f1da1d92ab99337c6511a6b994e9bc0da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166780
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-08 19:59:19 +00:00
Konstantin Shcheglov 103465c90c Report MAIN_HAS_MORE_THAN_TWO_REQUIRED_POSITIONAL_PARAMETERS and MAIN_HAS_REQUIRED_NAMED_PARAMETER.
Bug: https://github.com/dart-lang/sdk/issues/43559
Change-Id: If74634187d411c0b008133b59c1c3e23e87319c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166309
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-10-08 00:05:16 +00:00
Sam Rawlins 19ada0706e Report indirectly exporting @internal typedef
This type of exposure was brought up by Lasse at https://github.com/dart-lang/sdk/commit/afbb8f9063eaabf80fd3dfcd67ff2d3c07be2395#r42686423.

New "Indirect exposure" section in the doc: https://docs.google.com/document/d/130E4qfsjqRWtSNpIoNM628zVwGP-8W4J1P7W3wzJG8c/edit#

Change-Id: If38889b2134719804aa8cbaf613c8eb33cb6d949
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166180
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-06 21:58:23 +00:00
Konstantin Shcheglov d03dd09e0f Report CompileTimeErrorCode.MAIN_IS_NOT_FUNCTION
Bug: https://github.com/dart-lang/sdk/issues/43557
Change-Id: I773cd09a164c37444b9765ebc445477467bb7665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-04 17:25:51 +00:00
Brian Wilkerson cd897bc86c Remove the diagnostic default_value_in_function_typed_parameter
This diagnostic is obsolete because the parser also produces a
diagnostic for this situation.

Change-Id: I5c5f7fc734ddeb5cfaaba9cc9980efe174aeb4e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164461
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-09-25 04:35:53 +00:00
Sam Rawlins 863821476c Analyzer: Report invalid use of internal members
Bug: https://github.com/dart-lang/sdk/issues/28066
Change-Id: Iee39fee48340fb9311a8f7a07d1ae7aa474a22f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163961
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-23 17:51:49 +00:00
Sam Rawlins 51840c501a Analyzer: add two checks for the @internal annotation.
The meta package does not yet have an `internal` constant;
this CL just adds one to the mock packages for testing.

Two checks are implemented:

* Hint if an @internal annotation is found on an element which is
  already part of a package's public API (based on file path).
* Hint if an element annotated with @internal is exported from a
  package's public API.

The notion of "public API" is also implemented for each type of Package:
BasicPackage, BazelPackage, GnPackage, PackageBuildPackage,
and PubPackage.

Bug: https://github.com/dart-lang/sdk/issues/28066
Change-Id: Ifc2709028afcd241f59e802f5952539f717704c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163126
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-18 23:04:06 +00:00
pq 62abba754b validate returns of @doNotStore
See: https://github.com/dart-lang/sdk/issues/42497

Change-Id: I86516a19eb7a6560f95ea888ab1384208da222f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162821
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-14 23:59:08 +00:00
Jens Johansen e6ffc0b285 [parser] Issue different warnings for missing identifier based on whether the token is used or not.
E.g. "var = 42;" now has a different error message than "var default = 42;".

Fixes #22553

Change-Id: I58affe988569d8e79190b63f7267b471a1b0ebc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162182
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-14 08:55:18 +00:00
Jens Johansen b0acaea1e5 [parser] Recover written out binary operators
* Add mechanisms to try out a recovery and only perform it if is
  successful.
* Recover written out binary operators, e.g. "a xor b", "a or b" etc.
  This fixes #26810 and is also how these operators are written in e.g.
  Kotlin. This might be somewhat controversial though.
* Adds a mechanism to _replace_ a token by another token.
  This might be controversial.
  It is done because just inserting the operator causes the same rewrite
  to be attempted on the same token stream several times (at least with
  the way the token stream is parsed via the CFE) in turn causing it to
  be recovered *sometimes*. This is now avoided by actually replacing
  the token.

Change-Id: Icfa806045575d2aa2e5f35126708651b275bcf84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162003
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-10 06:23:33 +00:00
pq f5a0e185d2 invalid @doNotStore assignment analysis
Another pass at https://dart-review.googlesource.com/c/sdk/+/159841 (reverted) with a guarding type-check.



Change-Id: Ia270be4e880d71642a96c5ab93a306efba1ceedb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160961
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-01 02:38:17 +00:00
Sam Rawlins 44d88979ea Analyzer: Add LanguageCode, moving implicit-dynamic codes from StrongModeCode
Change-Id: Idd787c71137b7bdee9db3168b085861bf461bfd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-25 17:01:50 +00:00
Brian Wilkerson d5088c0a8f Reland the CL to "Add a hint for the new Target annotation".
This reverts commit 50946855dc.

The bug that caused dartdoc to fail has been fixed by restoring the
creation of the invalid field. An issue has been created to update the
dartdoc package to stop using the invalid field, and the field will
need to be removed after dartdoc has been updated and pulled into the
SDK.

Change-Id: Ia7e282972e541a33b379872fbcd57a137a9c8a25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-08-25 16:53:10 +00:00
David Morgan 50946855dc Revert "Add a hint for the new Target annotation"
This reverts commit 351a1cc489.

Reason for revert: caused a generator to fail, b/166257389

Original change's description:
> Add a hint for the new Target annotation
> 
> Change-Id: I5d8723eead20bb68407ce2a23e8de6cb9ae8a4de
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159921
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

TBR=scheglov@google.com,brianwilkerson@google.com

Change-Id: I16af4403867d31f731d1efafce2c0c2be405df9c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160102
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2020-08-25 14:20:52 +00:00
Brian Wilkerson 351a1cc489 Add a hint for the new Target annotation
Change-Id: I5d8723eead20bb68407ce2a23e8de6cb9ae8a4de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-08-24 18:04:47 +00:00
David Morgan a249594de9 Revert "invalid @doNotStore assignment analysis"
This reverts commit 1e2772d106.

Reason for revert: Analyzer crash: b/165866426

Original change's description:
> invalid `@doNotStore` assignment analysis
> 
> TODO: follow-up with an `extensions_test`
> 
> Change-Id: Ie3d18229daf347885128d02e4b751436a8a0643f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159560
> Commit-Queue: Phil Quitslund <pquitslund@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

TBR=brianwilkerson@google.com,pquitslund@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Icfddee0e62fef3691b446ce92531f9281863880a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159841
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2020-08-24 07:26:06 +00:00
pq 1e2772d106 invalid @doNotStore assignment analysis
TODO: follow-up with an `extensions_test`

Change-Id: Ie3d18229daf347885128d02e4b751436a8a0643f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159560
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-20 23:58:06 +00:00
Konstantin Shcheglov 25edea3d8d Issue 43100. Verify local variable reads for null safety.
Bug: https://github.com/dart-lang/sdk/issues/43100
Change-Id: Ia8ece4de32f65d7912e534ce61936a45f2c768c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-20 15:50:50 +00:00
Jens Johansen 8bca93872a [parser] Better error message for annotations on type arguments
This CL changes the message given in the situation identified in
https://github.com/dart-lang/sdk/issues/22314

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

Change-Id: Ibd47dd419d52673ae0d9e32039e0a635c1e09543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158388
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2020-08-17 07:43:52 +00:00
Paul Berry 06aff09656 External/abstract field support: prohibit a field from being both external and abstract.
Change-Id: I8c4dd136dc8c6518fddda68cfcb360cea8386942
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-13 16:11:34 +00:00
Paul Berry a3b15aefca External variable support: do not allow external variables to be late.
Although this error condition is not reported by the parser, the
language grammar does not it, so from a customer perspective it is a
parser error.  Accordingly, it has been assigned a ParserErrorCode and
is reported by the AstBuilder, as we do for other similar errors.

Change-Id: I22aad9b0acd27bf6e60dfb393837d48a49fc336b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158365
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-13 03:53:38 +00:00
Paul Berry ff987cc0ad External variable support: do not allow initializing abstract fields/variables.
There are three ways to initialize a field/variable, so we have to
check for three error conditions:
- At the declaration site
- Via a field formal parameter
- Via a constructor initializer

Change-Id: I14caa38aaf2265966a19c68525f1458ff9d116f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158363
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-13 02:42:38 +00:00
Konstantin Shcheglov 022812983e Enforce uniqueness of ErrorCode.uniqueName
Remove duplicate ParserErrorCode(s).

R=brianwilkerson@google.com

Change-Id: I8c8e4e3433f7147a728888cf5735bbecbc8297c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158204
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-12 00:40:59 +00:00
Konstantin Shcheglov 2f031c7121 Report WRONG_NUMBER_OF_TYPE_ARGUMENTS_EXTENSION.
R=brianwilkerson@google.com

Change-Id: I4c56a4535c4ae26dec9aaae9791774ad3ace365c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-11 21:54:10 +00:00
Paul Berry 87f0d5d9dc Abstract field support: do not allow abstract fields to be late or static.
Although these error conditions are not reported by the parser, the
language grammar does not permit them, so from a customer perspective
they are parser errors.  Accordingly, they have been assigned
ParserErrorCodes and reported by the AstBuilder, as we do for other
similar errors.

Change-Id: I79d0ad1dcad518981b8b649c117df326279008f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157800
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-10 19:27:13 +00:00
Konstantin Shcheglov 8405d7c8e3 Remove dart2jsHint option, verifier, and tests.
R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: I95b88940c862d463af03e85fcdf0f4bf81c2fbd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157641
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-10 19:19:43 +00:00
Paul Berry 92315c4b2d Abstract field support: do not allow initializing abstract fields.
There are three ways to initialize a field, so we have to check for
three error conditions:
- At the declaration site
- Via a field formal parameter
- Via a constructor initializer

Fixes #42981

Change-Id: Ifc32a28ffb62d60fd2171d4980e88da9eebcb481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157664
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-08 13:36:52 +00:00
Sam Rawlins d169af6f7d Analyzer: remove unnecessary this
Change-Id: I85a769e0c32159ac2a6422d3a60d160bda40d9b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156488
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-01 06:16:31 +00:00
Sam Rawlins b8ce4baf7e Remove 'checked mode' from checked_mode_compile_time_errors
Change-Id: I6576eb186149d540ce2dbc0e0aab7177ff4727be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156484
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-07-31 19:20:58 +00:00
Mike Fairhurst 59600f2b46 [analyzer] Improve existing non-generative constructor errors
As opposed to the parent CL which creates a new error for cases where no
non-generative constructor is available at all, these improvements
include a bugfix to the previous error message.

The previous message was incorrect in saying 'expected {0} but factory found',
because the argument passed to '{0}' was the factory constructor that
was found, rather than any kind of expected constructor signature.
Fixed.

Also, for implicit constructors, break out the error message to
deliberately explicitly describe that this affects the implicit
constructor.

I considered making an error code for implicit super initializers as
well, (ie `class Foo extends Bar { Foo(); }`), but don't think it is
necessary/common/etc.

Change-Id: I0643ad00abbfb2848cbd2f8f1f83e7c33d4fb846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155831
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-30 05:12:40 +00:00
Mike Fairhurst e0164ec47e [analyzer] Fix #25874, confusing error for extending Exception.
In the case of extending Exception, the raised error is around the
configuration of the constructors. However, there is no valid
configuration of constructors to be found, and therefore, the better
user facing message is to say that the class cannot be extended as
written.

Change-Id: I5950d438877c450c44cdc914f9f20d7779a64768
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154126
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-30 05:12:40 +00:00
Sam Rawlins f23f450e11 Analyzer: Move CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH to compile-time
Many of the tests were highly redundant. Subtyping has been
consolidated, so the tests don't need to cover a dozen different ways
to subtype a class.

Change-Id: I04448790d3a74690d0edb57f15146a6c3b8f2173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-07-30 00:34:29 +00:00
Konstantin Shcheglov 8de8a1c226 Move codes from StaticTypeWarningCode into CompileTimeErrorCode.
They are all errors now.

Change-Id: If48d38e38e845fd5b5a950dd5514bf1cbbce03d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-27 16:44:15 +00:00
Sam Rawlins 1a829bbde0 Analyzer: Recategorize COULD_NOT_INFER as CompileTimeErrorCode
Change-Id: I2aec1fd6499fcbcc35e7cf9b765dd43559d3ef67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155846
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-07-26 22:27:39 +00:00
Konstantin Shcheglov ba92b78acd Move errors from StaticWarningCode to CompileTimeErrorCode.
Bug: https://github.com/dart-lang/sdk/issues/42821
Change-Id: I153c48d7a2e4a02026928e6203aacf8f2dc029ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155849
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-26 04:19:25 +00:00
Sam Rawlins c65b444145 Analyzer: Move TOP_LEVEL_CYCLE to be a compile-time error
Also remove duplication with RECURSIVE_COMPILE_TIME_CONSTANT.

Also write some tests for TOP_LEVEL_CYCLE.

Change-Id: I33cb765236a83bd925f9f0c6e65ac9398761c699
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155701
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-24 15:11:38 +00:00
Sam Rawlins 6c9b885e57 Remove StrongModeCode.INVALID_PARAMETER_DECLARATION; it's redundant
You can see in the included test that we already report
`FIELD_INITIALIZING_FORMAL_NOT_ASSIGNABLE`.

Change-Id: Ib7c4177627120a31910d3929d61f5337cb869b1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155281
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-07-23 20:30:50 +00:00
Sam Rawlins 8796382840 Analyzer: Move invalid_super_invocation to compile-time error
Change-Id: Id8be8473b2516cfc15c226edaaf25dadf3a90d3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155549
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-23 18:15:04 +00:00
Sam Rawlins 23cf1230d0 Analyzer: Re-categorize StrongModeCode.INVALID_CAST_* codes as CompileTimeErrorCodes
I found literally zero tests for INVALID_CAST_FUNCTION_EXPR, and I was
unable to write any code that triggers it. :/

The rest are classified as compile-time errors in CFE; I am confident
that "compile-time error" is the correct classification.

Change-Id: Ib0cf543b983f8e28b45d40cc9cd4dc9f14b2f387
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155302
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-07-22 00:34:45 +00:00
Sam Rawlins bbe6bb9823 Analyzer: Improve generator return error messages
Fixes https://github.com/dart-lang/sdk/issues/27468

In addition convert both ILLEGAL_ASYNC_GENERATOR_RETURN_TYPE and
ILLEGAL_SYNC_GENERATOR_RETURN_TYPE to CompileTimeErrorCodes.

Change-Id: I5f09f3d77dad52b4ba524c86b3e07ac5fac905fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-07-18 15:28:06 +00:00
Sam Rawlins d90daf9154 Analyzer: Report unused optional parameters of private functions
Fixes https://github.com/dart-lang/sdk/issues/29731

This change produces UNUSED_ELEMENT hints for optional parameters
for which no arguments are ever explicitly given, under the following
circumstances:

* parameter is for a constructor, method, or top-level function which
  is not accessible outside the library,
* function is never torn-off (all bets are off once its been torn off),
* method does not override a method in which the matching parameter is
  required,
* method does not override a method with a matching paramter, in which
  an argument is given for the matching parameter.

Change-Id: Idabf051f55140b62a440dc63ca0234f22598a5e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152730
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-17 19:30:27 +00:00
Sam Rawlins 907da64b02 Analyzer: Redefine NOT_INSTANTIATED_BOUND to be an error.
All StrongModeCodes are being redefined.

https://github.com/dart-lang/sdk/issues/33545

Change-Id: I247c6584eba386edfd7babecb08adf5ccc9344ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154748
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-07-17 13:42:58 +00:00
Sam Rawlins f58ef23d58 Analyzer: Remove unused DYNAMIC_INVOKE code
This code is never reported.

Change-Id: I452e75682c188b4d89e8415f1f4050b2765cd267
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154744
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-07-16 21:46:04 +00:00
Brian Wilkerson d4ac7066b7 Improve diagnostic message when short circuiting (issue 42599)
Change-Id: I456bc50792dfdb30c281578d0d54ffa9e2af6474
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154161
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-07-15 21:19:49 +00:00