Commit Graph

7567 Commits

Author SHA1 Message Date
Paul Berry 65d157b5bb Fix type of receiverTypeObject in AssignmentVerifier.verify.
It was not necessary for this argument to support both `String` and
`DartType`; we can ensure that we always pass in a `DartType` by
calling `ClassElement.thisType`.

Change-Id: I94ac2fed7495b8267edea003d1fd088649c2d4a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217620
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-11-01 15:32:50 +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 243fb5c383 analyzer: Support non-proper rename type alias constructor tear-offs
An alternative to https://dart-review.googlesource.com/c/sdk/+/218582

In the case of a constructor tear-off through a non-proper rename type
alias, we store the type alias on the FunctionState in constant
evaluation.

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

Change-Id: I3bcbc11fceafc3a688eb956cf0459ad1dbde6307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218746
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-11-01 04:29:01 +00:00
Konstantin Shcheglov 0d74a3e436 A few renames of TypeName to NamedType.
Change-Id: Ie0eae6906457a28665855eb16371ad2230d1104a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218743
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-31 21:51:00 +00:00
Konstantin Shcheglov 56bb1d56e1 Rename AstTestFactory methods that return NamedType.
Change-Id: I2546ca0352b4149509d80ad6dde97b2eb686491b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218741
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-31 19:33:00 +00:00
Konstantin Shcheglov a4ebee9438 Use NamedType in ResolvedAstPrinter.
Change-Id: I8241a175a851cc1fe97a0daebd065f2a1ec75656
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-31 19:32:40 +00:00
Konstantin Shcheglov 19661d7f72 Fix errors in mock SDK.
Change-Id: I27263ddbad45881d92a98ec237851dbed37cc4da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218666
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-29 20:17:50 +00:00
Konstantin Shcheglov c1b3d96e97 Enable named_arguments_anywhere in analyzer unit tests.
Change-Id: Ie83d07dd3c2fe16459abcd2b534440078c66a4b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218660
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-29 18:16:09 +00:00
pq aad6da844e respect awaited used results
Fixes: https://github.com/dart-lang/sdk/issues/47569

Change-Id: If5391899603ad6ee4295d1d3a8fabba9a26a958f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2021-10-29 18:09:23 +00:00
Sam Rawlins 8f756bf96b Add CommentReferableExpression, for expressions which can be used in a CommentReference
* Replace `identifier` field with `expression`, which means deprecating
  `identifier`, redirecting users to `expression`. For now, `expression`
  always returns an Identifier. In a future breaking release, it will
  return other CommentReferableExpressions.
* SimpleIdentifier, PrefixedIdentifier, PropertyAccess,
  ConstructorReference, FunctionReference, and TypeLiteral are all
  CommentReferableExpressions, but support is not implemented yet to
  parse CommentReferences with those contained expressions.

Bug: https://github.com/dart-lang/sdk/issues/47444
Change-Id: I1905afecf3878cd7dca6e275ef0a2ab80500eb4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216320
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2021-10-29 16:38:09 +00:00
Sam Rawlins 6d276f9fd6 analyzer: Fix instantiated type parameter in function reference error
This fixes language/const/instantiated_function_constant_test

Change-Id: I06f42480f8a55de1c6d75b2b5845bcefb769fa78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218540
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-29 05:12:02 +00:00
Sam Rawlins 0da6894247 Implement Generic Function Instantiation via wrapping node
This is a re-land for https://dart-review.googlesource.com/c/sdk/+/217880.

The primary difference is the call-sites of
insertGenericFunctionInstantiation. There are more, and many more test
cases.

This is a non-breaking change (when analyzing code at language version
2.14 and earlier). If constructor-tearoffs is enabled (language version
2.15), then FunctionReference nodes are inserted, to represent generic
function instantiation. Constant evaluation can then use the
`typeArgumentTypes` to instantiate arbitrary function-typed
expressions.

If constructor-tearoffs is not enabled, generic function instantiation
continues to take place at a SimpleIdentifier, PrefixedIdentifier, or
PropertyAccess only, with constant evaluation using
SimpleIdentifier.tearOffTypeArgumentTypes.


Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Icf876cb6866bc1030e0cefaaafe221757d5b5639
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-27 19:25:35 +00:00
Konstantin Shcheglov d7718a934d Issue 47073. Inherit covariant-by-declaration from any candidate.
Initial: https://dart-review.googlesource.com/c/sdk/+/217081
Reverted: https://dart-review.googlesource.com/c/sdk/+/217288

Presubmit:
https://fusion2.corp.google.com/presubmit/tap/405776629/OCL:405776629:BASE:405789171:1635310230957:629680d7

Bug: https://github.com/dart-lang/sdk/issues/47073
Change-Id: I5458d60d0bf5cb88488ebd3fb21b0e45ab4ccfde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-27 16:35:58 +00:00
Samuel Rawlins ccf75d6539 Revert "Implement Generic Function Instantiation via wrapping node"
This reverts commit 1c8f56fb13.

Reason for revert: This breaks package:collection at
ListComparableExtensions.binarySearch, at
`comparable ?? compareComparable`:

The argument type 'Function' can't be assigned to the parameter type
'intFunction(E, E)'. #argument_type_not_assignable

Original change's description:
> Implement Generic Function Instantiation via wrapping node
>
> This is a non-breaking change (when analyzing code at language version
> 2.14 and earlier). If constructor-tearoffs is enabled (language version
> 2.15), then FunctionReference nodes are inserted, to represent generic
> function instantiation. Constant evaluation can then use the
> `typeArgumentTypes` to instantiate arbitrary function-typed
> expressions.
>
> If constructor-tearoffs is not enabled, generic function instantiation
> continues to take place at a SimpleIdentifier, PrefixedIdentifier, or
> PropertyAccess only, with constant evaluation using
> SimpleIdentifier.tearOffTypeArgumentTypes.
>
> Bug: https://github.com/dart-lang/sdk/issues/46020
> Change-Id: Ie370c00c8a2ce7a4791ac9cdb7459a01339a79c1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217880
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

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

Change-Id: Ie76cd703e05cbf65fecaa76b72e829f8272b8307
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/46020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218089
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-10-26 21:05:32 +00:00
Sam Rawlins 0fe438812b analyzer: Correct const is and is! for null safety
Fixes https://github.com/dart-lang/sdk/issues/46081
Change-Id: I59a52a51739974e318ea32f3eb3b39dedbb5a9fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218084
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-10-26 17:24:31 +00:00
Sam Rawlins 1c8f56fb13 Implement Generic Function Instantiation via wrapping node
This is a non-breaking change (when analyzing code at language version
2.14 and earlier). If constructor-tearoffs is enabled (language version
2.15), then FunctionReference nodes are inserted, to represent generic
function instantiation. Constant evaluation can then use the
`typeArgumentTypes` to instantiate arbitrary function-typed
expressions.

If constructor-tearoffs is not enabled, generic function instantiation
continues to take place at a SimpleIdentifier, PrefixedIdentifier, or
PropertyAccess only, with constant evaluation using
SimpleIdentifier.tearOffTypeArgumentTypes.

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Ie370c00c8a2ce7a4791ac9cdb7459a01339a79c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217880
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-26 16:57:12 +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
Konstantin Shcheglov 873005502d Deprecate AnalysisResult.path/uri
Change-Id: I0908a49fd8983dbcbdf585c026190ab0fefb45c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218061
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-25 22:04:39 +00:00
Konstantin Shcheglov 1aa6fa4776 Refactor Cider FileState.
The general direction is to make pieces of data that are produced
together to be stored together, and so be available together.

_FileStateLocation is created before FileState, so it is separated.

Any FileState has some unlinked state, so we pass _FileStateUnlinked
into the constructor. In Cider we don't refresh files, we discard
them and recreate. So, '_unlinked' is a final field.

Practically FileState works as a wrapper around _FileStateUnlinked.
It could probably have been inlined into FileState. My excuse for
not doing this is that in DAS, at least at the moment, we keep
FileState instances and refresh them with replacing their unlinked
states. So, they should be separate objects.

Change-Id: I9439a4021e6efa9e4375eceb5eecf534eabda168
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217860
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-25 17:47:59 +00:00
Paul Berry 5eb9461a03 Change ExpectedError.messageContains to a list.
This will allow tests to verify multiple substrings are present in the
error message without having to include all the intervening text
(which would make the tests brittle).

Change-Id: I8aeaa7edb7b6da0eadf8c12e8c01d7e0805d9b27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217822
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-25 08:47:20 +00:00
Konstantin Shcheglov b61605b5e6 Remove double.CAPITAL constants.
Presubmit: https://fusion2.corp.google.com/presubmit/tap/404922794/OCL:404922794:BASE:405010232:1634915532338:93e197a/targets

Change-Id: Ib29a079678eced84e6d3a4f322c64a548b3668c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217781
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-23 18:22:33 +00:00
Konstantin Shcheglov e916841bcc Deprecations and renames for getXyz() in AnalysisDriver.
Presubmit looks green.
https://fusion2.corp.google.com/presubmit/tap/405055453/OCL:405055453:BASE:405057194:1634949541100:f811db8d/targets

Change-Id: I8f7f036003650611760523dd315ba89724a29b0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217805
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-23 17:15:33 +00:00
Paul Berry 85bac75b0e Ensure that function reference resolution assigns an element and type when the method is inherited.
Change-Id: I2053c625617aa03bcad9ffa920c0ff27823a0a9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217701
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-22 12:57:17 +00:00
Konstantin Shcheglov a270ec6f59 update to_source_visitor.dart
GenericTypeAlias from docs
/// A generic type alias.
///
///    functionTypeAlias ::=
///        metadata 'typedef' [SimpleIdentifier] [TypeParameterList]? = [FunctionType] ';'
but you forgot semicolon

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

GitOrigin-RevId: 45625c19e5782ced108a301731c9b8ccb5057339
Change-Id: Id3a11bbc391368aceb0f95368a8661b2a27cada2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-21 18:35:26 +00:00
Sam Rawlins 57a2e7ef7c Insert new ImplicitCallTearoff nodes at assignability checks.
Fixes half a dozen tests for
https://github.com/dart-lang/sdk/issues/46020

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

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

There are two cases where implicit tear-off conversion should be
performed in desugared code. Because the analyzer does not desugar,
we just make additional checks in assignability:
* for-in statements, where the iterable is an Iterable<C> and C is
  a callable class, and the for-in element is function-typed.
* spread-elements, where the iterable is an Iterable<C> and C is
  a callable class, and the typed literal element type is a
  function type.

This is a breaking change as it involves removing implicit tear-off
conversion from TypeSystem.isAssignableTo.

However, it passes google3 today. :D

Change-Id: I9d852adadc11c92b3f7dbf130965d003c68b2b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217157
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-20 21:29:24 +00:00
Simon Binder 02b8407d81 [analyzer] Resolve annotations on local variable elements
Metadata is attached to a `VariableDeclarationList`, not the individual
declarations therein.
Even though annotations from the list are copied down into the local
variable elements, the resolver did not set the `element` property on
those annotations which is required for computing the constant value in
a later step.
This is fixed by making the resolver visit the declaration list instead
of individual declarations.

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

Change-Id: Id6e47e6fa878e61be5279fa4127262deb73ab1c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217363
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-20 20:07:12 +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
Konstantin Shcheglov 311760f49c Deprecate 'withInformative' in link()
Change-Id: I6da8baf8cbac140b20351b5b93fc6858603ba8d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217380
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-20 04:03:32 +00:00
Konstantin Shcheglov aed00dc37c Revert "Issue 47073. Inherit covariant-by-declaration from any candidate."
This reverts commit 60535b95de.

Bug: https://b.corp.google.com/issues/203423390
Change-Id: Id096d464b4b992153dd9f3b140b475ec2b7b3b43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217288
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-19 23:40:41 +00:00
Konstantin Shcheglov b381186c91 Use runtimeTypesEqual() for FunctionState.isIdentical()
Bug: https://github.com/dart-lang/sdk/issues/46840
Change-Id: I48d257554ad5e4305168e37b18a6dbfc119b78c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217284
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-19 19:10:23 +00:00
Konstantin Shcheglov 3cd8dfe95b Deprecate MockSdk, switch to createMockSdk().
Change-Id: I512cd93af2f4aeab91f3d739c58c47572f3c4ede
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217151
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-19 18:52:15 +00:00
pq 4d35418b6f fix unused_result false positive
Fixes: https://github.com/dart-lang/sdk/issues/47473

Change-Id: Idc8a7c029dd3f081cda5c0d3d2ca4929156fcc98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217161
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-19 17:09:02 +00:00
Konstantin Shcheglov 5fff311900 Add createMockSdk(), a replacement for MockSdk.
This makes MockSdk a factory for FolderBasedDartSdk.
In a next CL I will deprecate MockSdk, and update SDK clients.

Change-Id: I1a24c70d2e9b902150f80ccaaa8a84d5e385058f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217150
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-18 21:37:54 +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
Paul Berry 267323de7d Remove unnecessary declaration names from error codes.
The errors HintCode.INVALID_VISIBLE_FOR_OVERRIDING_ANNOTATION and
CompileTimeErrorCode.EXTENSION_CONFLICTING_STATIC_AND_INSTANCE didn't
really need to name the enclosing declaration, since the user can
easily find the enclosing declaration from the location of the error
message.  Without this change, there are some situations where an
error message would awkwardly refer to an unnamed extension as having
the name `<unnamed>`.

Change-Id: I4ddec389f18e78167464b1b5c35556e92dd1c15f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216860
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-18 18:26:04 +00:00
Konstantin Shcheglov 60535b95de Issue 47073. Inherit covariant-by-declaration from any candidate.
Bug: https://github.com/dart-lang/sdk/issues/47073
Change-Id: I1ae779d50f1e4ee63f005098f9a22615c744480a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217081
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-18 16:45:59 +00:00
Paul Berry 72cfca37aa Change WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR to use .new consistently.
This changes the behavior of the
CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR error
so that instead of referring to unnamed constructors with a clumsy
trailing `.` (e.g. `The constructor 'Foo.'`), it refers to them in the
same way the user's code refers to them (so, e.g. if the user's code
refers to the constructor using the name "new", the error message does
too).

Change-Id: Ib29b64ce0122d8928b3a59f5e0125561da8f73d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216840
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-18 10:01:38 +00:00
Daco Harkes 8986a2bcd9 [analyzer/ffi] Non const type argument error on receiver
Bug: https://github.com/dart-lang/sdk/issues/36780

Change-Id: I2dd98d58f0045d25afcfb92a43f858e5f2bcc1fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217009
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-18 07:46:19 +00:00
Paul Berry 189aeead47 Fix reporting of INSTANCE_ACCESS_TO_STATIC_MEMBER from within an extension.
Previously, if a piece of code inside an extension tried erroneously
to refer to a static class member using instance access, the error
CompileTimeError.UNQUALIFIED_ACCESS_TO_STATIC_MEMBER_OF_EXTENDED_TYPE
would be reported.  This change corrects the error to
CompileTimeError.INSTANCE_ACCESS_TO_STATIC_MEMBER.

In addition, the responsibility to report the error
CompileTimeError.INSTANCE_ACCESS_TO_STATIC_MEMBER is shifted fully to
the resolver (previously, it was split between the resolver and the
error verifier).

Change-Id: Idcd1a3b8a1e226fed692900838c3d2d3c0585d4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-17 06:22:30 +00:00
Konstantin Shcheglov 0a8091f908 Change ConstructorElement.displayString to 'Class' or 'Class.constructor'
Change-Id: I0918cd9f97d2ec3af008f5369cbd048fc5137dc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216922
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-10-16 22:28:40 +00:00
Paul Berry 79fd228bbb Improve test output when error messages don't match.
We now print any non-null values of `ExpectedError.message`,
`ExpectedError.messageContains`, and
`ExpectedError.correctionContains`.  This should make it easier to
understand what has gone wrong when there's a mismatch due to an
incorrect message or correction string.

Change-Id: I50359008ad15b894b1a5c5512ff6847d07193408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216820
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-16 12:55:58 +00:00
Konstantin Shcheglov 7c17777ecc Rewrite 'C<args>.<synthetic>' into ConstructorReference.
It will make things more consistent, and helpful for completion.

Change-Id: Id21b7544862af25c5feb13c7c8864bdbf5d88227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217027
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-15 19:48:50 +00:00
Konstantin Shcheglov 71da05e920 When const evaluating ConditionalExpression, if the condition is unknown, checks both then/else for errors.
Bug: https://github.com/flutter/flutter/issues/91906
Change-Id: I29057d9b5704fe9850a6ba2ed1416472c7e1abc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217025
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-15 19:32:30 +00:00
Brian Wilkerson 1aaed6385f Remove unnecessary ignore comment
Change-Id: I0498ff6ec3f7e5b88da07970fd01773749e21097
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217021
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-15 17:17:30 +00:00
Daco Harkes be195ad329 [analyzer/ffi] Report non-const fromFunction argument
* Adds missing error to analyzer.
* Adds analyzer test.
* Adds analyzer/cfe negative test.
* Formats the analyzer/cfe negative tests file.

TEST=pkg/analyzer/lib/src/generated/ffi_verifier.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

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

Change-Id: Ibc2a3d1c3b4b4d8b2285605f084237a55253fb20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217007
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2021-10-15 11:21:23 +00:00
Konstantin Shcheglov 7154635d4d Issue 47404. Evaluate 'kIsWeb = identical(0, 0.0)' to BoolState.UNKNOWN_VALUE
Bug: https://github.com/dart-lang/sdk/issues/47404
Change-Id: I29626bd11379580c6a090384c57882de98f619b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216923
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-10-14 23:04:49 +00:00
Paul Berry 72daafd70c Fix correction message for CompileTimeErrorCode.INSTANCE_ACCESS_TO_STATIC_MEMBER.
Previously, it assumed that the static member was always a class; it
could also be an extension or a mixin, and the extension could be
unnamed.  This change causes extensions (named and unnamed) to be
handled properly.

Handling mixins will be more complicated (since it will require
expanding ElementKind to include mixins), so that is not addressed
right now (see https://github.com/dart-lang/sdk/issues/47452).

Change-Id: Ie01a6abfdb560d97e545d36255909da19500b3c4
Bug: https://github.com/dart-lang/sdk/issues/47452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216680
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-14 22:13:55 +00:00
Paul Berry fe0e921728 Test CompileTimeErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR with .new.
Change-Id: If4bb810904581527e8e1dd806a1c5db319bc8566
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-10-13 22:06:07 +00:00
Sam Rawlins cebf84d729 Allow any type parameter as a potentially const expression
Bug: https://github.com/dart-lang/sdk/issues/46020

Fixes language/const/instantiated_function_constant_test

Change-Id: I7b9a92a7abca213919d0850dd68c5b2d3d4857f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216601
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-10-13 14:47:36 +00:00
Sam Rawlins 20da76f9f8 Update parser to allow unnamed constructor reference in comment reference
Code like `/// See also [List.new].` will be accepted as a valid comment
reference.

Test in front_end, analyzer, analysis_server.

Remove TODOs in analyzer for reporting a reference to an element whose
library is not the library in which the comment is found.

Bug: https://github.com/dart-lang/sdk/issues/47446
Change-Id: Ifa19278f92ac003082b62b121c66f0559c0152e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216583
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-13 14:09:26 +00:00