Commit Graph

3110 Commits

Author SHA1 Message Date
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
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
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 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
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
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
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
Sam Rawlins 957fe1a0f6 Consolidate const InstanceCreationExpression tests
Evaluation of a constructor's initializers (field initializers, assert
initializers, and super initializer) are all so much complexity separate
from evaluating a simpler const object that they deserve their own test
classes.

* Move all tests using assert initializers from very old
  non_error_resolver.test and from constant.dart to
  InstanceCreationEvaluatorTestCases.
* Move many test cases into *TestCases so they are tested in pre- and
  post-null safety.
* Introduce more basic tests for assert initializers.

Bug: Preparation for https://github.com/dart-lang/sdk/issues/46081
Change-Id: Ie3e21d2457b1ba34667f85a0f5e3ef0e558f5cb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-10-12 21:08:35 +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
Johnni Winther cf1591f935 [cfe] Refactor detection of instance type variable access in static context
NamedTypeBuilder is now created with a state that determines whether it
can validly be resolved to an instance type variable.

Change-Id: I1e7f5f8e05a5f68ec18a063476b6cda291a1aca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214643
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 11:58:04 +00:00
Konstantin Shcheglov 2b36a3945d Issue 47364. Add context messages to TYPE_ARGUMENT_NOT_MATCHING_BOUNDS.
We include two pieces of data:
1. If the named type was raw, the instantated type.
2. If the type was not regular bounded, also the inverted type.

Bug: https://github.com/dart-lang/sdk/issues/47364
Change-Id: Idc8fce998f755e68bee0ada2caa715b59101cc84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215484
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-10-04 22:23:00 +00:00
Sam Rawlins 8029600b24 analyzer: Use correct instantiated type in const function-typed assignment
This fix is pretty simple; we have the inferred type available on [node], so we just need to create a new DartObject which uses that type.

Bug: https://github.com/dart-lang/sdk/issues/46020
Change-Id: Ib53ff381b8c9c864f97eb2a4869d3798e028c30f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215003
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-10-01 12:51:59 +00:00
Sam Rawlins 5e0f4c24c5 Move function reference const tests to evaluation_test.dart
This change moves tests out of the older-style test file. In addition:

* additional tests for uninstantiated function tearoff identity.
* additional tests for using a type parameter as a type argument in a
  function tearoff in a const expression.

Change-Id: I6c6a6db13144e02794a62d78337013b4a525549a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214139
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-24 05:39:59 +00:00
Konstantin Shcheglov b553298024 Deprecated TypeName, use NamedType instead.
Change-Id: Ic7c2bef44277db3d4b3de495fbf9fbadf15f3db8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214223
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-23 06:08:34 +00:00
Konstantin Shcheglov e1b5db7478 Deprecate getters that return TypeName, replace with returning NamedType.
Change-Id: I13764db3da27d5eabe972aab32cdf587a7de53e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214220
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-22 21:01:58 +00:00
Konstantin Shcheglov 1c125b4868 Deprecate AstVisitor.visitTypeName(), add visitNamedType().
Change-Id: I736a568068c2acfdc7074bb16b11fd38b656a13a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214135
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-22 19:15:54 +00:00
Konstantin Shcheglov dfd7d7b37a Deprecate NodeList<TypeName> getters and replace with NodeList<NamedType>.
Change-Id: I6a772a7bca75e9c2ab4b3612d51c04ea6114ed6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214130
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-22 16:25:56 +00:00
Konstantin Shcheglov 056a6cae31 Replace more references to TypeName with NamedType.
Change-Id: I6981aac2ca0d17bd3dd75c37689ef66319214cc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-22 00:34:30 +00:00
Konstantin Shcheglov b41ae230a2 Replace many casts to TypeName with NamedType.
Change-Id: I485b7a3e268c59c435f02e3357dc5dcf256e627e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214067
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-21 20:32:38 +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
Sam Rawlins 4ff0cb2ac3 analyzer: Migrate some tests from constant_test to value_test.
In particular:

* integerDivide tests are well-covered in value_test.
* There was not great coverage for logicalShiftRight, so I improved
  coverage in value_test.
* remainder tests are well-covered in value_test.
* shiftLeft tests are well-covered in value_test.
* shiftRight tests are well-covered in value_test.
* times tests are well-covered in value_test.

Change-Id: I4d9e584119dbd9c05ad5deae783429636a0b9218
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213803
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-09-19 21:54:30 +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
Konstantin Shcheglov 3409b2a0e8 Remove 'featureSet' from TestAnalysisContext.
Change-Id: Ide3eb73562aa70b0daf82d12f66f2001b7a3c735
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213533
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-15 23:20:05 +00:00
Konstantin Shcheglov 1d6f4c742f Rename subtypes of AbstractTypeSystem[WithoutNullSafety]Test
Change-Id: I2ab8a19a5bae165b4904e412f783b69e11344cc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213120
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-13 16:05:09 +00:00
Konstantin Shcheglov dea3861e5f Stop using FeatureSet.forTesting() in analyzer/.
Change-Id: Ic4de7d6bcb3397aaa86ff6d82cce1531afbffa50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213118
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-11 18:46:27 +00:00
Konstantin Shcheglov ddce4b3535 Rename AbstractTypeSystemTest -> AbstractTypeSystemWithoutNullSafetyTest, AbstractTypeSystemNullSafetyTest -> AbstractTypeSystemTest.
There are a few subclasses that could be renamed to be more consistent,
will do this in a separate CL.

R=brianwilkerson@google.com

Change-Id: I3adccf32e463b4c622a08d206d2ec0d9e49e72cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213117
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-11 01:17:26 +00:00
Konstantin Shcheglov a512845350 Use AbstractTypeSystemNullSafetyTest in more places.
R=brianwilkerson@google.com

Change-Id: Idcba60ab93ff4783a35da3c009e63094eb09e3d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213111
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-11 00:15:46 +00:00
Sam Rawlins 8132940357 Support function types in const is checks
Fixes https://github.com/dart-lang/sdk/issues/47161

Change-Id: Ibe39331217c88bccc331d4d569f469905c70c66e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212867
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-10 21:46:49 +00:00
Sam Rawlins 1122440fc7 Fix accidentally commented tests
Change-Id: I7dc14ea10f769dd36ff15f3ee9ffc40ce78cf4bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213105
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-10 20:11:17 +00:00
Konstantin Shcheglov 78c09bcc38 Update latestSdkLanguageVersion to 2.14
Eventually we will remove it completely, but for now let's make it
more correct.

Change-Id: I09c338bcf2e12aecb75b5b9646104e97cf35705c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213030
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-10 20:01:47 +00:00
Konstantin Shcheglov 79950b989f Remove ExperimentStatus.testingSdkLanguageVersion
Change-Id: Ia8993c3ca29c79ede835db46fe5e1d660a3621d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213104
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-10 19:22:57 +00:00
Sam Rawlins a3a7e2786c analyzer: Allow function tearoffs in const context
`typeInstantiate` is a new "operation" in const expressions. It doesn't
do much, but does find the correct staticElement to be used in the
FunctionState.

Instantiated static type is necessary on a FunctionMember.

Change-Id: I15b72c870ce9bfc2b8b1fc592553c988e9cc243c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212604
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-09-10 14:28:18 +00:00
Sam Rawlins e319cfa6aa Enable in-line ignores per 'type' such as 'lint'
This uses the class ErrorType which may be an outdated field on ErrorCode, but it works for a prototype.

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

Change-Id: I98de8faf7f3ad738e9e27b0d5dd5add531b78b77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211460
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2021-09-10 01:30:27 +00:00
Konstantin Shcheglov 73d90bd400 Issue 47171. Apply Substitute also to InstantiatedTypeAliasElement.
Bug: https://github.com/dart-lang/sdk/issues/47171
Change-Id: Ifcc9ea79cdcd2cc55a876e25fc6bd6d710180d1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213022
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-09-10 00:38:38 +00:00
Dmitry Stefantsov ab508bb2d1 [cfe] Add basic parsing support for extension show clause
Change-Id: I63847a06ff7370dd1b92fc6b4b706c684f15638e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209909
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-09-07 10:35:12 +00:00
Sam Rawlins 394b76fd61 Add tests for constructor tearoff as const function.
Also update some TODOs.

Change-Id: I02c883e717a3315892a99879ef45aba804183c86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-09-03 14:20:58 +00:00
Konstantin Shcheglov ae41b91336 Use named parameters in ParameterElementImpl, make parameterKind required.
So, 'parameterKind' is never null.

Change-Id: Id5d17a3cfc9795d3dcec4b2f1e8bb5c372f339fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211607
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-30 16:23:17 +00:00
Jens Johansen 5caa4365d7 [parser] Add beforeSynthetic to SyntheticStringToken
E.g. if reporting a missing ";" after a SyntheticStringToken (e.g. a
inserted identifier) before this CL it would go to the next token and
say we expected the ";" after that, when really we expected it *before*
that token.

Change-Id: I2c358e017edb2f661e307eba03dddaee889086d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205799
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-30 11:56:30 +00:00
Paul Berry 080ed7a37f Consolidate flow analysis feature detection logic into FlowAnalysisHelper constructor.
This should reduce the risk of mistakes, since there are many call
sites that create FlowAnalysisHelper objects, and we would have subtle
bugs if the call sites disagreed about when certain pieces of flow
analysis logic should be enabled.

Change-Id: I2c58eebbe05724b231107a0681c9ea668f5d968f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211502
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-28 15:24:38 +00:00
Paul Berry 1b4f067e0b Parser: Reduce the set of disambiguation tokens for resolving < ambiguities.
When the parser encounters a `<` after an expression, it must choose
whether to interpret it as a relational operator or a <typeArguments>
selector.  The disambiguation rule is: if the `<` and the tokens
following it *can* be parsed as <typeArguments>, and the token that
follows is a member of a privileged set of tokens, then it is treated
as a <typeArguments> selector; otherwise it is treated as a relational
operator.

This change reduces the privileged set of tokens to the following:

- the "continuation tokens" `(`, `.`, `==`, and `!=`
- the "stop tokens" `)`, `]`, `}`, `;`, `:`, and `,`

The names "continuation tokens" and "stop tokens" reflect the
rationale for choosing these tokens:

- Continuation tokens are tokens that we can reasonably imagine a
  programmer wanting to place after a type argument selector to
  *continue* the expression.  For example, `if (List<int> == T) ...`
  is allowed.

- Stop tokens are tokens that can't possibly follow a `>` that is a
  relational operator, because they *stop* the expression that's in
  progress.  For example, `var x = List<int>;` is allowed.

If a user wants to follow a <typeArguments> selector with a token
other than the ones above, they'll have to parenthesize the
expression.  So for example, if they want to do `List<int> + 1` (which
could be meaningful if an extension method defined `operator +` for
the type `Type`), they will have to use parentheses, and instead write
`(List<int>) + 1`.

Bug: https://github.com/dart-lang/language/issues/1806
Change-Id: I2816cdac24e55eac3cb3e9920e276404c1228d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210941
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-27 14:56:16 +00:00
Johnni Winther ce4e7705f2 [cfe] Handle explicit instantiation in implicit creation syntax
Closes #46719
Closes #46887

Change-Id: I4ad0f1bb4ab847a44f749113c6446f62a474143c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211260
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-26 11:59:48 +00:00
Konstantin Shcheglov 4d42e73295 Report EXPERIMENT_NOT_ENABLED instead of ANNOTATION_WITH_TYPE_ARGUMENTS.
On one hand this is less precise, OTOH this tells which feature and
the language version it requires.

Change-Id: I1d24a2d7cf2c7b7ca305d5bfc9f094fce0734bc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210644
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-19 20:20:26 +00:00
Jens Johansen 7bf731a547 [parser] Special-casing of '}' (like eof) wrt. looksLikeName
Change-Id: I55fb4c10931831630f9c1621addef7fbe9d5a9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205797
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-19 06:41:58 +00:00
Paul Berry a34bf90313 Make ResolverVisitor.flowAnalysis non-nullable.
Previously, the only circumstance in which it was null was during a
few unit tests, and this is easily fixed by creating a
FlowAnalysisHelper object when setting up those tests.

Change-Id: Ida083ec218a2b1ee910bca747a8f5eb320828527
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-16 17:35:04 +00:00
Paul Berry 8dc6c5ecb0 Allow is or as to follow type arguments in constructor tearoff disambiguation.
Fixes #46888.

Bug: https://github.com/dart-lang/sdk/issues/46888
Change-Id: I780a53a2d5a45a8630935c9be5c886d96ef1a2ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209881
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-13 15:41:31 +00:00
Paul Berry 9ed173fcad Stop tracking scopes in ResolverVisitor
With this change, the analyzer logic for performing scope lookups is
now fully separated from the logic for doing type analysis and flow
analysis (ResolverVisitor now only does the latter; the former is done
by ScopeResolverVisitor and ResolutionVisitor).  The analyzer now has
a similar separation of concerns between scope lookups and type/flow
analysis as the CFE does; this should help pave the way for sharing
resolution logic between the analyzer and the CFE in the future.

Change-Id: Ie006dfe1b5943bb361dc0aec4525e21572e21e5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209381
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-11 17:39:40 +00:00
Konstantin Shcheglov 766113bc54 Update latestSdkLanguageVersion to 2.13
Bug: https://buganizer.corp.google.com/issues/195648511
Change-Id: I7f882edaec42c6224a0863be96a41e1abd5b3329
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-08-10 11:56:43 +00:00
Paul Berry b7f8227c42 Remove dead code related to visitor-based lints.
In the two LibraryAnalyzer classes, the list of visitors is always
empty, so there are never any "visitor based lints" to run.  (I
suspect that all the visitor based lints were long ago converted to
use the node registry, leaving this code dead).

Removing the last remnants of the visitor based lint logic allows us
to remove the ExceptionHandlingDelegatingAstVisitor class, which in
turn allows us to move its logException method into a simpler class.
In a follow-up CL, I will expand on this class to allow its behavior
to be customized.

Change-Id: I1261a94572ea65eb220a58fb45f6d887e6497fe9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208140
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-30 14:48:04 +00:00