Commit Graph

549 Commits

Author SHA1 Message Date
Konstantin Shcheglov 8f2a27f940 Report ENUM_MIXIN_WITH_INSTANCE_VARIABLE
Change-Id: Idc15ea010fc0b7d7f4b551a2a4b8731bcfc74ad7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231325
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-03 00:03:49 +00:00
Konstantin Shcheglov 33b3c1d6c6 Report ILLEGAL_LANGUAGE_VERSION_OVERRIDE, when 'sourceLanguageConstraint' is set.
Change-Id: Ibbd786090a5a1a61da11f1e9de754202bdc454d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231322
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-02 20:20:39 +00:00
Konstantin Shcheglov 22a8295295 Report INVALID_REFERENCE_TO_GENERATIVE_ENUM_CONSTRUCTOR instead of INSTANTIATE_ENUM when enhanced-enums.
Change-Id: I634b3e50641b2b696b4d9e164266b43fdc72f137
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231063
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-01 23:58:45 +00:00
Konstantin Shcheglov af598f9d25 Report NON_ABSTRACT_CLASS_HAS_ENUM_SUPERINTERFACE.
Change-Id: Iec3daeba6b069c80e01baf4bc070059209d1ac4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231045
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-01 23:00:25 +00:00
Konstantin Shcheglov dcc1b8bc18 Report NON_CONST_GENERATIVE_ENUM_CONSTRUCTOR.
Change-Id: I1a087a3b554d5d5439d43b0798d14a46310f1bfe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231048
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-01 18:18:55 +00:00
Konstantin Shcheglov 17d2a0b755 Report SUPER_IN_ENUM_CONSTRUCTOR.
Change-Id: I403b51eed9a0f685e56433a2b567b8a38a95e15b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231049
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-02-01 18:18:35 +00:00
Konstantin Shcheglov edbf6300a1 Remove MIXIN_INFERENCE_NO_POSSIBLE_SUBSTITUTION.
When we cannot infer types, we leave `M<dynamic>` and report
other errors.

Change-Id: Ice6ebabf4bc844ee21aa1cc842e6496fcf8b3c11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226660
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-01-06 22:17:45 +00:00
Brian Wilkerson ccc1656eb0 Improve the message when the required keyword needs to replace the required annotation
Fixes https://github.com/dart-lang/sdk/issues/46841

Change-Id: If318064a901f3cf1cbcf117ad392d72a9cf004fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-01-05 16:38:25 +00:00
Konstantin Shcheglov 23d238f02c Report when super-formal parameter type is not a subtype of the associated parameter type.
Change-Id: Id74910d59ae753940ec116ba865305e35eb69465
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226484
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-01-05 01:33:57 +00:00
Konstantin Shcheglov a34925dc19 Report more specific errors for implicitly invoked unnamed super constructor when super-parameters feature is enabled.
Change-Id: Ib2e82f0ab86c606c512d9f5d1787dbbfad753449
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-01-04 20:09:51 +00:00
Brian Wilkerson dc833c2119 Remove the unreported mixin_declares_constructor diagnostic
Change-Id: I3af5b52e3269b155b871004b89a3702530d325d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-01-04 19:03:25 +00:00
Konstantin Shcheglov 8bf64b3b4a Remove CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME
Bug: https://github.com/dart-lang/sdk/issues/48045
Change-Id: I3f408a61e0f789f22a13443fcddeb3964bacc591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-01-04 17:59:45 +00:00
Konstantin Shcheglov bd3fbd1682 Report a few errors for super-formal parameters in explicit super-constructor invocation.
Change-Id: I75cdc08ab26fba01fb44f387737ee44d6b09eaa8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225980
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-12-31 17:31:43 +00:00
Konstantin Shcheglov 2ad5ab51bd Report an error if super-parameter outside non-redirecting generative constructor.
Change-Id: Ib36f3266aeb0a4fd6992fb61695fd80257a51646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225900
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-12-30 17:48:42 +00:00
Sam Rawlins b16b0322b9 Reland "analyzer: Report missing return for nullable return types"
This is a reland of 93bcdf0329

Original change's description:
> analyzer: Report missing return for nullable return types
>
> This is implemented as a new HintCode, but it could be a new Warning, if
> we'd like to stop adding new Hints.
>
> There is also a dartfix available in this change.
>
> Fixes https://github.com/dart-lang/sdk/issues/46656
>
> Change-Id: I8e93e576d2bd09a8ff02d52c12bbb9ec6adff9c2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220803
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

Change-Id: I369b2dc38db0dc278f50b55aab67da53a5a63a8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/225400
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-12-22 18:46:14 +00:00
Alexander Thomas 3b5d06e449 Revert "analyzer: Report missing return for nullable return types"
This reverts commit 93bcdf0329.

Reason for revert: Broke google3 rolls.

Original change's description:
> analyzer: Report missing return for nullable return types
>
> This is implemented as a new HintCode, but it could be a new Warning, if
> we'd like to stop adding new Hints.
>
> There is also a dartfix available in this change.
>
> Fixes https://github.com/dart-lang/sdk/issues/46656
>
> Change-Id: I8e93e576d2bd09a8ff02d52c12bbb9ec6adff9c2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220803
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

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

Change-Id: I122be4cb1d07f7f95334d2d5cbac1de4bd597d15
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224950
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-12-22 08:38:52 +00:00
Sam Rawlins 93bcdf0329 analyzer: Report missing return for nullable return types
This is implemented as a new HintCode, but it could be a new Warning, if
we'd like to stop adding new Hints.

There is also a dartfix available in this change.

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

Change-Id: I8e93e576d2bd09a8ff02d52c12bbb9ec6adff9c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220803
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-12-21 18:22:03 +00:00
Daco Harkes acdf82de17 [vm/ffi] ABI-specific integers
This CL adds support for users defining integers which are mapped to
differing sizes and signedness based on the application binary interface
the Dart VM is running on.

Notable implementation design decisions:
- ABIs are open world, so that adding an ABI to the Dart VM does not
  break existing definitions. Thus, we only figure out in the VM that
  we're missing a mapping. We throw compile-time errors.
  - In AOT, these show up in the precompilation step.
  - In JIT, these show up as `_CompileTimeError` at runtime. Note that
    these can be caught. So in subsequent compilation steps we need to
    ensure that we also throw the same compile-time error.
- We match on the call-sites (streaming_flowgraph_builder) rather than
  method bodies (kernel_to_il) of AbiSpecific loads and stores so that
  we can compile for the int-size of the call site.

API design decisions:
https://github.com/dart-lang/sdk/issues/42563#issuecomment-981774001

Closes: https://github.com/dart-lang/sdk/issues/42563

TEST=tests/ffi_2/abi_*_test.dart
TEST=tests/ffi/function_*_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart
Change-Id: I8c8df36fab939b6fb614c5f1ee8e1bf46b6e9521
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-nnbd-linux-release-try,app-kernel-linux-debug-x64-try,benchmark-linux-try,dart-sdk-linux-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,pkg-linux-debug-try,vm-canary-linux-debug-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-fuchsia-release-x64-try,vm-kernel-checked-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-linux-debug-x64c-try,vm-kernel-mac-debug-x64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-android-release-arm64c-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221501
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-12-16 22:07:00 +00:00
Konstantin Shcheglov f317d7c1db Breaking changes for analyzer version 3.0.0
Internal presubmit:
https://fusion2.corp.google.com/presubmit/tap/366560067/OCL:366560067:BASE:415321249:1639080094301:ae113907

Change-Id: Idf9cb7d98f490409bec4eab8833b95328ece9e86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212610
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-12-09 23:07:19 +00:00
Daco Harkes c3b50826dd [analyzer/ffi] ABI-specific type support in analyzer
TEST=pkg/analyzer/test/src/diagnostics/abi_specific_integer_mapping_test.dart

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

Change-Id: I7ae6e05073e6f28a42b5f8f7d06c9b5b91c510a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221821
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-12-02 12:10:27 +00:00
Sam Rawlins bd57f9a837 analyzer: Explicitly return null in nullable return functions
Related to: https://github.com/dart-lang/sdk/issues/46656

Change-Id: I5c015e9827cc7b7ac26f198371709c124b6c28ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221565
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-11-30 05:20:05 +00:00
pq b403d4bf73 Reland "hints for text_direction_code_points"
This is a reland of 39008c8243

Original change's description:
> hints for text_direction_code_points
>
> Fixes: https://github.com/dart-lang/sdk/issues/47611
>
> Related: https://github.com/flutter/flutter/pull/93034
>
>
> Change-Id: Ia6bac44e1c9a7ef25f01683b8414b9818822cb7f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219123
> Commit-Queue: Phil Quitslund <pquitslund@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Kathy Walrath <kathyw@google.com>

Change-Id: Ib200aa2e6f1a323a6d01cc3c051657fd48f41251
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219750
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
2021-11-10 00:09:33 +00:00
Siva Annamalai 90749574b6 Revert "hints for text_direction_code_points"
This reverts commit 39008c8243.

Reason for revert: breaks G3 builds please see https://ci.chromium.org/p/dart/builders/ci.sandbox/google

Original change's description:
> hints for text_direction_code_points
>
> Fixes: https://github.com/dart-lang/sdk/issues/47611
>
> Related: https://github.com/flutter/flutter/pull/93034
>
>
> Change-Id: Ia6bac44e1c9a7ef25f01683b8414b9818822cb7f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219123
> Commit-Queue: Phil Quitslund <pquitslund@google.com>
> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Kathy Walrath <kathyw@google.com>

TBR=lrn@google.com,brianwilkerson@google.com,pquitslund@google.com,sra@google.com,kathyw@google.com

Change-Id: I82c2b471bc9566222db4616bba501534c35b4f9e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219747
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-11-08 22:48:43 +00:00
Sam Rawlins 8900608365 Report fewer duplicate errors for invalid superinitializers
Fixes https://github.com/dart-lang/sdk/issues/45958

Move check out of old checker.dart, into (less old) error_verifier.dart
and move test case out of old checker_test.dart. Add valid test case.

Rename INVALID_SUPER_INVOCATION to SUPER_INVOCATION_NOT_LAST, and
correct comment on that code (it has a parameter).

Do not duplicate report that code with MULTIPLE_SUPER_INVOCATIONS or
with SUPER_IN_REDIRECTING_CONSTRUCTOR.

Change-Id: I26e28b345fd8cef8ed2c9ec89ab12b56ea1c2f37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218982
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-11-08 18:53:42 +00:00
pq 39008c8243 hints for text_direction_code_points
Fixes: https://github.com/dart-lang/sdk/issues/47611

Related: https://github.com/flutter/flutter/pull/93034


Change-Id: Ia6bac44e1c9a7ef25f01683b8414b9818822cb7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219123
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
2021-11-08 18:38:28 +00:00
Paul Berry 0b94228695 Enforce that all ErrorReporter arguments come from a limited set of types.
This change ensures that the only types ever passed to ErrorReporter
arguments are String, DartType, int, Uri, or Element.  A few call
sites had to be changed so that instead of passing in AST nodes they
passed in the result of calling `toString` on those AST nodes.

In future CLs, I plan to move toward a system where instead of passing
the message arguments to ErrorReporter as a list of `Object`, we call
a `withArguments` method that's specific to each error; that method
will have a specific list of argument types that it supports, so that
if we accidentally pass the wrong things into an error message, the
problem will be detected at compile time (instead of the user just
seeing a confusing error message).

The `withArguments` methods will be code generated from annotations in
the analyzer's `messages.yaml` file.  Keeping the set of types
supported by those `withArguments` messages small should help simplify
the code generation process, and provide flexibility for how errors
are represented in the future.

Change-Id: I4a793db2fe5b1344199b770898634b61be41ad11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216301
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-11-02 14:23:12 +00:00
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 0a39aa7cf6 Make all analyzer message arguments non-nullable.
Cases where `null` was being passed as an argument to formatting a
message have all been fixed in previous CLs; all that remains to do is
change the type system to reflect that, and insert `!`s in a few
places.

This brings us one step closer to being able to make analyzer message
formatting type safe.

Change-Id: Id9e0d0b32f29cde0fdc5227417b7a2e3fc3b443d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216272
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-20 11:31:51 +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