This reverts commit bc8c7cf782
Reason for revert: Breaks parsing less common conditionals (e.g. b ? c = true : g();)
Original change's description:
> Add support for parsing simple nullable types
>
> ... as part of adding NNBD as outlined in
> https://github.com/dart-lang/language/issues/110
>
> This only supports parsing simple nullable types
> such as int? and List<int>? while subsequent CLs
> will add support for parsing more complex types.
Change-Id: I49a21a85dca19241e3b23ed5c9fb6084e70f2000
Reviewed-on: https://dart-review.googlesource.com/c/87284
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This reverts commit 11d081d115
Reason for revert: Breaks parsing less common conditionals (e.g. b ? c = true : g();)
Original change's description:
> Add support for simple nullable type return value in generalized function type
>
> This only supports nullable return values of the form
>
> <identifier> '?' 'Function' '(' ...
>
> This is an increment CL in the ongoing effort to add nullable type support
> as outlined in https://github.com/dart-lang/language/issues/110
Change-Id: I99bce29619d4e448193e3c81fa86a982791b1f77
Reviewed-on: https://dart-review.googlesource.com/c/87283
Reviewed-by: Dan Rubel <danrubel@google.com>
This adds a new accessor in the fasta parser support classes
for determining the number of type arguments. This will be used
when adding support for set literals to disambiguate a set literal
from a map literal.
Change-Id: If32c12d198f6d88fb06527817cec038c22428d53
Reviewed-on: https://dart-review.googlesource.com/c/84461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
The scanner associates '<' with '>' and '>>',
but the parser cannot use '<'.endToken/endGroup reliably
and wastes time updating that token's endToken/endGroup field.
This CL updates type info parsing to ignore '<'.endGroup
and step through the token stream (which it has to do anyway),
for improved parsing.
This CL causes a handful of existing tests to fail (marked as @failingTest)
and test failures will be addressed in a subsequent CL.
Change-Id: I788e9a74cd2891f98f44bba15d5669febfec6c64
Reviewed-on: https://dart-review.googlesource.com/70001
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This is the first CL of several needed to fix typedef parsing
when there is no space between the type parameters and the `=`.
typedef F<T>= T Function(T);
* Fix some typedef parsing failures
* Add new consts for simple type var ending with ">>" and ">="
* Update computeType and computeTypeParamOrArg to return new consts
* Extract splitGtEq/GtGt/GtGtEq from splitEndGroup
* Hide internal TypeInfo and TypeParamOrArgInfo consts
Change-Id: Ice550f5b15df1f3cad616a2a342644974f14d8ee
Reviewed-on: https://dart-review.googlesource.com/69261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
As of this CL, events for type variable declarations occur
in the following order:
* beginTypeVariables
* beginTypeVariable for each type variable in the declaration
* handleTypeVariablesDefined
* endTypeVariable for eah type variable in the declaration
* endTypeVariables
Revising the order of events facilitate removing the hack
in BodyBuilder.beginTypeVariables in a future CL.
This is another slice of https://dart-review.googlesource.com/c/sdk/+/57661
so that it can be landed in a more incremental fashion.
Change-Id: Ief0ad766c12f1ca9d53a8ec8d3c08b41166b2897
Reviewed-on: https://dart-review.googlesource.com/61940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This improves recovery when parsing type arguments in
* top level fields and functions
* class members
and when parsing type parameters in
* top level functions
* class declaration
* class methods
Change-Id: I7dbb520d6bb39c0d13b27698658dafe580f2b16c
Reviewed-on: https://dart-review.googlesource.com/56681
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This CL is the next step in replacing parseType and improving recovery.
It introduces a new parseVariables method for parsing type parameters
(aka type variables) method in addition to improving recovery in the
parseArguments method.
Change-Id: I4049528152a7c731771d7a8145e5f79729165d79
Reviewed-on: https://dart-review.googlesource.com/55301
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This is another step to replacing parseType with computeType
and improving recovery when parsing types and type arguments.
This adds a new computeTypeParamOrArg utility which returns
one of a couple constants for common situations or an instance
of ComplexTypeParamOrArg. The computeType function and
some places in ComplexTypeInfo class have been updated to use
this new method, but there are additional places that will be
tackled in subsequent methods.
Change-Id: I7012b65580e9dbc74b9424456262aa3c0367f48b
Reviewed-on: https://dart-review.googlesource.com/53641
Reviewed-by: Peter von der Ahé <ahe@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
Rename the TypeInfo constants and related constants in preparation
for refactoring and improving type argument and type parameter parsing.
Change-Id: I5a741ee06f373800973942c233490fe83916e39c
Reviewed-on: https://dart-review.googlesource.com/52140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This improves recovery when parsing conditional import expressions
by repositioning the synthetic closing ')' that was inserted by the
scanner in a less than optimal location.
This approach relies on the beforeSynthetic field being set correctly.
While the scanner still sets the 'next' and 'beforeSynthetic' fields
directly for efficiency, most other functions which update an existing
token stream have been revised to call 'setNext()' rather than setting
the 'next' field directly. This ensures that the 'beforeSynthetic' field
will be correctly updated.
Change-Id: Id631fd600c64d1feaf00593acb74a7070e354f07
Reviewed-on: https://dart-review.googlesource.com/52120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This CL improves recovery when a type is required to interpret
"Foo.", ".", and ".Foo" as malformed prefixed type references.
When a type is *not* required, each of the above are still interpreted
as no-type-reference.
Change-Id: Ia20caa8619821d24c5b16fd0015cee03987ee2a6
Reviewed-on: https://dart-review.googlesource.com/51900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This CL updates the beginFormalParameters event to include
the covariant and const/final/var modifiers, and cleans up
a number of unused classes and methods including:
* the original implementation of ModifierContext/Recovery
* handleModifier and handleModifiers events
Change-Id: Ie89a202d17872fba85cd1a477091472a8d2d223b
Reviewed-on: https://dart-review.googlesource.com/51380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This CL cleans up the TypeInfo library including:
* moving ComplexTypeInfo to type_info_impl.dart
* splitting up and enhancing the tests
* adding a new ensureTypeOrVoid method for use in a subsequent CL
Change-Id: I2d13f74152f8c4eb2e8b3ee504f108225cfa60eb
Reviewed-on: https://dart-review.googlesource.com/51080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
This CL extracts the core logic out of parseType into a new computeType
function. This enables the TypeContinuation logic in parseType to be
moved into the callers of parseType so that recovery can be improved.
Change-Id: Ibded6f5eacfeaccdc6c56e234b305596d9582a92
Reviewed-on: https://dart-review.googlesource.com/45760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>