Commit Graph

496 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
Sam Rawlins 383f45ac7e Add DEPRECATED_NEW_IN_COMMENT_REFERENCE diagnostic
This is a new HintCode for code in which comment-references is enabled.

`/// See also [new List].` is marked as deprecated, preferring a direct
reference (or "tear-off") of a constructor, like
`/// See also [List.new].`.

Additionally, a new quick fix supports making the above conversion,
taking into account both unnamed and named constructors.

Bug: https://github.com/dart-lang/sdk/issues/47446
Change-Id: Iec68ef21bd03198ea822979f6f0048cc655023c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-26 16:52:51 +00:00
Paul Berry ce8ee6cf03 Check the number of arguments when instantiating AnalysisErrors.
Change-Id: I45fa2a560b7368370fae4a7a94d8f52136e92486
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213821
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-23 14:13:33 +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
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
Clement Skau 998d5f5a9b [vm/ffi] Adds FFI transform FfiNative instance methods.
- Allows FfiNative annotation to be attached to non-static
  methods of classes.
- Transforms non-static instance methods to static, adding
  wrappers with the receiver as an extra, implicit first paramters.
- Transform all parameters and arguments to Pointer if the object
  being passed supports it (i.e. extends NativeFieldWrapperClass1).
- Adds compile time errors for cases where the FfiNative annotation
  doesn't align with the annotated function. Taking into account
  implicit receivers and converted Pointers.
- Adds complimentary Analyzer checks for the above errors as well.
- Adds tests for the transforms, compile time errors and analyzer
  changes.

TEST=Adds new tests for instance methods, analyzer changes.

Change-Id: Idf54430acf2728a650008333b149b254941290ad
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213773
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-10-12 10:58:44 +00:00
Sigmund Cherem 24a7318725 [analyzer] - remove the missing_js_lib_annotation hint
The web compilers now accept `@JS` annotations on classes and members
directly and no longer requires an additional `@JS` library annotation at the
library level. As a result, we no longer need the
`missing_js_lib_annotation` hint.

Support for this landed a few months ago in
https://github.com/dart-lang/sdk/commit/0845ebaad8e2f4ec2d6c05a15ba4551300e44d65
and was released in Dart 2.12.0.


Change-Id: I39acbf6149499e561f18f909dd09f2d2499f5054
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215684
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2021-10-07 00:22:32 +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
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
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
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
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