Commit Graph

512 Commits

Author SHA1 Message Date
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
Sam Rawlins 51d5c58d6a Remove redundant imports from analyzer
Many of these are a redundancy between
    'package:analyzer/src/generated/source.dart' and
    'package:analyzer/src/generated/source_io.dart'

I chose to remove the latter, for no particular reason.

Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: Ic69b09fd502c978cef9e4d3b8a0ef9acd92d5184
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213849
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-09-20 15:22:51 +00:00
Paul Berry af18bfacc1 Fix analyzerCode corresponding to CFE error ConstructorWithTypeArguments.
Previously we had identified this error with the analyzer error code
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR, but
they're not the same error at all.  As a result, code like this:

    var x = new a.b.c<C>();

would lead to the bogus analyzer error text "The constructor '{0}.{1}'
doesn't have type parameters." (with the placeholders "{0}" and "{1}"
visible to the user).

With this change, the error text is the same as that from the CFE: "A
constructor invocation can't have type arguments after the constructor
name."

Change-Id: Ib69d1ff8f7089e59b71d2dcd9a8ec51edffd94dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213621
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-09-17 10:48:59 +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
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 681243f881 [analysis_server] Support HACK, FIXME, UNDONE types for TODO comments
Fixes https://github.com/Dart-Code/Dart-Code/issues/2364.

Change-Id: I0c66e6443e9a1b0bb3795b6db29de81e43e52b61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-09-01 15:47:19 +00:00
Sam Rawlins c1e972a87d analyzer: Report error when unknown member is referenced off instantiated class
Fixes https://github.com/dart-lang/sdk/issues/47006

Change-Id: I0d27bd7fc7307b9bdb53b296bd5ecd7371048b16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211560
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-27 17:05:47 +00:00
Konstantin Shcheglov 9ac299bb0d Catch macro execution exceptions and report MACRO_EXECUTION_ERROR.
Change-Id: I43dbbba6c975d274fcc90907d6461be5bc750a1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211482
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-27 16:03:47 +00:00
Sam Rawlins 485c1962d3 analyzer: report tearoff of generative constructor of abstract class
From the spec:

> A compile-time error occurs if a constructor tear-off denotes a
> generative constructor declared in an abstract class.

Change-Id: Ic1bf3fd5a726f327a0dd80d180b7b88790514797
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210660
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-20 17:16:06 +00:00
Sam Rawlins c86bfe3e2c Correct type of CONSTRUCTOR_TEAROFFS_NOT_ENABLED code
Additionally, sort the UNUSED_RESULT_* codes.

This addresses comments in
https://dart-review.googlesource.com/c/sdk/+/209300

Change-Id: I4d3fd25703f6df59f8ad985352c87406e218b544
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-08-19 22:22:06 +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 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
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
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
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
Clement Skau 2f0b352e98 [VM] Adds compile-time error for non-static FfiNative
This makes it a compile-time error to add @FfiNative annotation
to any non-static function, such as an instance method.

TEST=tests/ffi/ffi_native_test.dart,pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

Bug: https://github.com/dart-lang/sdk/issues/43889
Change-Id: Ib9ec61345bb47e735ed635c5ceea15ab643f65a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207306
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2021-07-20 11:54:30 +00:00
Sam Rawlins 9ef9fce004 Report more errors on invalid explicit type instantiation function tearoffs.
When an expression which is not a type, not a constructor, and not an
identifier for a function, is torn off with type arguments, report
DISALLOWED_TYPE_INSTANTIATION_EXPRESSION.

When a function expression (without a name) is explicitly torn off with
the wrong number of type arguments, report
WRONG_NUMBER_OF_TYPE_ARGUMENTS_ANONYMOUS_FUNCTION. This separate error
code has text which does not have a slot for a function's name.

Add resolution for implicit receiver super-type instance method tearoff.

Bug: https://github.com/dart-lang/sdk/issues/46233
Change-Id: I3243e1824e191b6b703b1c995af5e1bd8a242915
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207140
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-07-18 02:04:04 +00:00
Konstantin Shcheglov 6058012cc0 Issue 45293. Report FfiCode.FIELD_MUST_BE_EXTERNAL_IN_STRUCT.
Removed error codes are not necessary, because external fields
don't allow initializers.

Bug: https://github.com/dart-lang/sdk/issues/45293
Change-Id: I7c1035b39013a7fdf2f49e2cb71909d9ad381ed8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-02 20:12:22 +00:00
Brian Wilkerson 66ec44c5f0 Add some missing error codes to the master list
Change-Id: I97886d2adafe5bd0ae07fe251642054617bf279a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205861
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-07-02 18:30:05 +00:00
Konstantin Shcheglov 44d5de1015 Issue 44987. Report an error if a Struct/Union subtype is instantiated.
Bug: https://github.com/dart-lang/sdk/issues/44987
Change-Id: I17aab811bece39dffaf2bc4e76049a76b3ea7361
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205740
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-07-02 18:17:48 +00:00
Sam Rawlins 48859a261f Add initial support for type literals with type arguments:
* type literals with explicit type instantiation
* the above feature, referring to a type alias
* the two above features, with prefixed elements
* reworked guards and TODOs for forthcoming constructor tearoffs.

Bug: https://github.com/dart-lang/sdk/issues/46233
Change-Id: I9c0b7ef16da0a105c4841e11e014ee2a21933d4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-07-02 03:48:45 +00:00
Simon Binder 8fbc2ad8c0 [analyzer] Diagnostics for invalid Future.value and Completer.complete
When Future.value and Completer.complete are used with a non-nullable
type argument and an argument that is absent or null, a runtime error
occurs.

This adds a diagnostic detecting those invalid usages.

Closes: https://github.com/dart-lang/sdk/issues/45319
Change-Id: Ifd9af70e002c351bf145f4a623105476feb213d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202622
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Simon Binder <oss@simonbinder.eu>
2021-06-23 14:47:51 +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
Konstantin Shcheglov 4936904e9a Prepare for -1 as nameOffset of synthetic PropertyAccessorElement(s).
Change-Id: Ia8f2760475e2bc465329c1bcdc08732d1a338ecc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203295
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-06-11 16:38:06 +00:00
Brian Wilkerson 2b1a93e233 Reland "[analyzer] Support hints for visibleForOverriding"
This reverts commit 465a8a8754.

Reason for revert: Internal issues fixed

Original change's description:
> Revert "[analyzer] Support hints for visibleForOverriding"
>
> This reverts commit 8357efa65c.
>
> Reason for revert: This caused some internal breakage because the annotation is not being used as defined by this CL. There is a path forward, but it requires reverting the CL temporarily. At least one problem is that the annotation is not allowed on a constructor, which is technically valid, but in practice might be something we want to allow anyway. While constructors aren't overridden, they do need to be called from subclasses.
>
> Also, it uncovered a minor problem: when the annotation is applied to an unnamed constructor the message contains an empty name.
>
> Original change's description:
> > [analyzer] Support hints for visibleForOverriding
> >
> > This adds support to detect whether an annotation is
> > `@visibleForOverriding` or whether such annotation is present on an
> > element.
> > Also, the analyzer now reports invalid uses of that annotation (when
> > the annotated member is static, in an extension or private).
> > Finally, we report hints when a member declared with that annotation is
> > uses outside of a method declaration.
> >
> > Closes: https://github.com/dart-lang/sdk/issues/46155
> > Change-Id: I368ea4be6bd5c1da5383a3c9dacdeee02a72af86
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202620
> > Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> > Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
>
> TBR=brianwilkerson@google.com,srawlins@google.com,oss@simonbinder.eu
>
> Change-Id: Ib9731dbebfc41d0d68aac0fb90faf3bd3ac1ef94
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202842
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

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

Change-Id: I6f8090e4a82edd88dc79078c7aa7b9f580ad8162
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-11 15:44:26 +00:00
Devon Carew 1acb443145 [analyzer] cleanup references to the .analysis_options file
Change-Id: I08f491b06925a420069019b77177839e8310843c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202868
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-06-09 15:52:31 +00:00
Brian Wilkerson 465a8a8754 Revert "[analyzer] Support hints for visibleForOverriding"
This reverts commit 8357efa65c.

Reason for revert: This caused some internal breakage because the annotation is not being used as defined by this CL. There is a path forward, but it requires reverting the CL temporarily. At least one problem is that the annotation is not allowed on a constructor, which is technically valid, but in practice might be something we want to allow anyway. While constructors aren't overridden, they do need to be called from subclasses.

Also, it uncovered a minor problem: when the annotation is applied to an unnamed constructor the message contains an empty name.

Original change's description:
> [analyzer] Support hints for visibleForOverriding
>
> This adds support to detect whether an annotation is
> `@visibleForOverriding` or whether such annotation is present on an
> element.
> Also, the analyzer now reports invalid uses of that annotation (when
> the annotated member is static, in an extension or private).
> Finally, we report hints when a member declared with that annotation is
> uses outside of a method declaration.
>
> Closes: https://github.com/dart-lang/sdk/issues/46155
> Change-Id: I368ea4be6bd5c1da5383a3c9dacdeee02a72af86
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202620
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>

TBR=brianwilkerson@google.com,srawlins@google.com,oss@simonbinder.eu

Change-Id: Ib9731dbebfc41d0d68aac0fb90faf3bd3ac1ef94
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202842
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-08 21:26:11 +00:00
Simon Binder 8357efa65c [analyzer] Support hints for visibleForOverriding
This adds support to detect whether an annotation is
`@visibleForOverriding` or whether such annotation is present on an
element.
Also, the analyzer now reports invalid uses of that annotation (when
the annotated member is static, in an extension or private).
Finally, we report hints when a member declared with that annotation is
uses outside of a method declaration.

Closes: https://github.com/dart-lang/sdk/issues/46155
Change-Id: I368ea4be6bd5c1da5383a3c9dacdeee02a72af86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-08 20:08:10 +00:00
Brian Wilkerson 01fb0a6e22 Add specialized messages for conflicting type parameters in mixins
Change-Id: I8d858226b2c93c15c3bf7610980672b064b40167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-06-06 21:51:11 +00:00
Konstantin Shcheglov b13e2c4a51 Report HintCode.DEPRECATED_IMPLEMENTS_FUNCTION
Change-Id: I044ad8f2577870889fe8981fc0f47ca798960b31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-06-04 17:32:52 +00:00
Sam Rawlins fd8607c8f4 Implement inference_failure_on_function_invocation checks
The "inference failure" checks implemented here are long overdue. They
are part of the strict-inference spec [1]. I think I caught most function
invocation cases. All of the work done to determine which error to report
and whether @optionalTypeArgs is annotated is done _after_ the check
for whether strict-inference is enabled, so this should have no effect
on code which does not opt in to that mode.

[1] https://github.com/dart-lang/language/blob/master/resources/type-system/strict-inference.md#function-call

Bug: https://github.com/dart-lang/sdk/issues/33749 and
Change-Id: Ic1d4321fb289acb118e0dbddd48ff917ad39d69a
https://github.com/dart-lang/sdk/issues/45371
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/201321
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-05-26 21:02:42 +00:00
Clement Skau 4d5055805f [VM/FFI] Adds FFI leaf calls.
This CL adds FFI leaf calls by adding `lookupFunction(.., isLeaf)`
and `_asFunctionInternal(.., isLeaf)`, which generate FFI leaf calls.
These calls skip a lot of the usual frame building and generated <->
native transition overhead.

`benchmark/FfiCall/` shows a 1.1x - 4.3x speed-up between the regular
FFI calls and their leaf call counterparts (JIT, x64, release).

TEST=Adds `tests/ffi{,_2}/vmspecific_leaf_call_test.dart`. Tested FFI tests.

Closes: https://github.com/dart-lang/sdk/issues/36707
Cq-Include-Trybots: luci.dart.try:vm-precomp-ffi-qemu-linux-release-arm-try,vm-ffi-android-release-arm64-try,vm-ffi-android-release-arm-try,vm-ffi-android-product-arm64-try,vm-ffi-android-product-arm-try,vm-ffi-android-debug-arm64-try,vm-ffi-android-debug-arm-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-precomp-nnbd-mac-release-simarm64-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try
Bug: https://github.com/dart-lang/sdk/issues/36707
Change-Id: Id8824f36b0006bf09951207bd004356fe6e9f46e
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179768
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-05-21 11:12:02 +00:00
Sam Rawlins 5d4032282b Warn about deprecated native extensions
Fixes https://github.com/dart-lang/sdk/issues/45759

Change-Id: I0162708a33aebec59edf6e7d3eb14b08e639e0af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200924
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-05-21 01:29:55 +00:00
pq 1bfa8610d1 add @useResult
See: https://github.com/dart-lang/linter/issues/1888

Change-Id: Idd529c86236a4c2692104dc36cb0a7f0d5dd35aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-05-19 18:04:32 +00:00
Sam Rawlins 2bcc415510 analyzer: Report unnecessary import directives.
In a given library, every import directive has a set of "used
elements," the subset of elements provided by the import which are
used in the library. In a given library, an import directive is
"unnecessary" if there exists at least one other import directive
with the same prefix as the aforementioned import directive, and a
"used elements" set which is a proper superset of the
aforementioned import directive's "used elements" set.

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

Change-Id: I4da43be36837cdafb07a0ab67a94e644f351e593
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177221
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-05-17 20:23:12 +00:00
JustWe b1c961233d [analyzer] verify annotation's const expression deferred imported error.
try to fix: https://github.com/dart-lang/sdk/issues/45418

Closes https://github.com/dart-lang/sdk/pull/45806
https://github.com/dart-lang/sdk/pull/45806

GitOrigin-RevId: 199c3bf0bdd7f834c9e10945a643d489e4b3658f
Change-Id: If465611ac01de679905b5bd7afefb1d9e0a70224
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-05-14 17:17:58 +00:00
Konstantin Shcheglov 920d1d85e1 Stop reporting StrongModeCode.TOP_LEVEL_INSTANCE_GETTER
Initial: https://dart-review.googlesource.com/c/sdk/+/195302
Reverted: https://dart-review.googlesource.com/c/sdk/+/196282

Internal presubmit looks green.
https://test.corp.google.com/ui#id=OCL:372759773:BASE:372759779:1620532577947:b5e08140

Change-Id: I7348692e1f34f26a9aca48902abb16df50fda2c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198920
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-05-09 18:51:18 +00:00
Brian Wilkerson 11831f4e01 Remove an error code that duplicates another
The two codes had the same message and were for two different ways to
do the same thing, so I don't think it's useful to users to have two
separate codes.

Change-Id: I41933d7cb3050e43ca2555fb75a0432a037d696a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/197640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-05-02 22:16:28 +00:00
Brian Wilkerson d92ed4d72f Unify duplicate_field_formal_parameter and final_initialized_multiple_times
I started doing this the normal way, but the two codes appear to differ
only based on whether the field was final, and I don't think that factor
is important to the nature of the error, so I think a single code is
sufficient.

Change-Id: I693dcfb1a2a4b47a8b82fe4860e7a61c82ca062e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-04-27 17:32:18 +00:00
JustWe 417e3ef225 [analyzer/ffi] Array dimensions non-positive check
Bug: https://github.com/dart-lang/sdk/issues/45540
Closes: https://github.com/dart-lang/sdk/pull/45784

GitOrigin-RevId: 09a3c9651488938597142f5a22b42e56ec965394
Change-Id: I1ea38a45aca836060de35e90b47a25f0d6b9947e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196245
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2021-04-26 09:17:47 +00:00
Konstantin Shcheglov 6a203ce308 [analyzer] add error check in not binary operator.
try to fix: https://github.com/dart-lang/sdk/issues/45659

Closes https://github.com/dart-lang/sdk/pull/45751
https://github.com/dart-lang/sdk/pull/45751

GitOrigin-RevId: ae4544cd41743ee1a5e0576ee64dd9544990b3d7
Change-Id: Ie4ccb05aa8f3df2d55e474056f69c56d6cca6a62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195882
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-24 00:04:32 +00:00
Paul Berry b10a592341 Add a url field to DiagnosticMessage.
This paves the way for allowing analyzer and analysis server clients
to format diagnostic message URLs in a special way (e.g. to make them
clickable).

Note that DiagnosticMessage is part of the public API of the analyzer,
so I've retained the old behavior in a deprecated fashion to avoid
breaking clients that don't yet handle diagnostic messages containing
URLs.

See
https://dart-review.googlesource.com/c/sdk/+/193749/comment/86d1ce4b_77a60b1e/
for additional discussion.

Change-Id: Iae9d43a2be7dbc67cb7cb82afe0a7824043d6113
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196101
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-23 20:34:32 +00:00
David Morgan d8479de94b Revert "Stop reporting StrongModeCode.TOP_LEVEL_INSTANCE_GETTER"
This reverts commit 649f7cf689.

Reason for revert: Breaks google3: b/185875256

Original change's description:
> Stop reporting StrongModeCode.TOP_LEVEL_INSTANCE_GETTER
>
> Change-Id: I947e1edb042825a5cfc3394d2554ad3272f86b91
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195302
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>

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

Change-Id: Ic019fa570f048e213290ac04d02d1b4655415b47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196282
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2021-04-21 10:22:18 +00:00
Konstantin Shcheglov 649f7cf689 Stop reporting StrongModeCode.TOP_LEVEL_INSTANCE_GETTER
Change-Id: I947e1edb042825a5cfc3394d2554ad3272f86b91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-20 04:53:39 +00:00
Konstantin Shcheglov 6628a0eca5 Stop reporting StrongModeCode.TOP_LEVEL_FUNCTION_LITERAL_BLOCK
Change-Id: I4e3aff4a16015910e1f3cb48e8dd12892e63531a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-14 18:38:05 +00:00
Konstantin Shcheglov cc265dc81c Stop reporting StrongModeCode.TOP_LEVEL_INSTANCE_METHOD
I will work on removing other such hints in following CLs.

Change-Id: I792ec4dde8b11c9e6117bb5d63ef9583cb86fadf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195185
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-14 00:43:08 +00:00
Sam Rawlins 5e040a20f8 analyzer: Improve span of use_of_nullable_value errors
This changes the span reported from the _receiver_ to
the _use_ (method name, property name, operator token).

I think this change is overall an improvement.
Specifically, its a great improvement for cmdline
output, where the receiver and the "use" are on
different lines.

One possibly weird change is that if the operator is `[]`,
then I only highlight the `[` character. I don't know if
there is a better place, and I think this is fine.

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

Change-Id: Ie66ddf04b4904a367575193106385dd63ee39985
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188680
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-02 02:43:48 +00:00
Konstantin Shcheglov 97daca81be Report an error when a type alias that expands to a type variable is used where a class is expected in hierarchy.
https://dart-review.googlesource.com/c/sdk/+/192743

Bug: https://github.com/dart-lang/sdk/issues/45450

Change-Id: I5d32236ddff7403eb739ca8b7de421f7f5a36ab6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193001
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-03-25 18:49:34 +00:00
Jens Johansen ac9b4aab8d [parser] More specific error messages when recovering new/const/Map/Set/List with said literals
Follow-up to https://dart-review.googlesource.com/c/sdk/+/190022

Change-Id: Id42336216267dcbf481ae6e111177e6296ea6779
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190881
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-03-25 13:27:03 +00:00
Sam Rawlins d693078bbf Analyzer: new diagnostic: UNNECESSARY_QUESTION_MARK
`null` is already a valid value of `dynamic` and `Null`, so adding a question
mark to make `dynamic?` or `Null?` is unnecessary, and could lead to confusion.

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

Change-Id: I710ff12935767dd635edfdb026033aa8e27e7804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190041
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-03-23 19:55:11 +00:00