This CL adds language tests for the simple identifier variation of enum shorthands. In these tests, we are testing prefix identifiers with a single simple identifier.
For example, `Decoration(fit: BoxFit.cover)` where `fit` has the type `BoxFit?`, we would be able to turn this into `Decoration(fit: .cover)` with enum shorthands.
The tests also test erroneous ways that someone can use the `==` operator like the shorthand not being on the RHS.
Bug: https://github.com/dart-lang/sdk/issues/57038
Change-Id: I03610db2a683e9c2cdf8c12a99c7808171377e3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393606
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
This change introduces the class `NullTypeImpl` to represent the
special type `Null`, which was previously represented as an ordinary
`InterfaceType`.
This class mirrors the CFE's `NullType` class. Adding it will
facilitate further code sharing between the analyzer and the CFE,
because it will allow code that's shared between the analyzer and CFE
to use `is` tests to recognize the type `Null`.
The new `NullTypeImpl` class always has a nullability suffix of
`NullabilitySuffix.none`, so it is impossible for the type `Null?` to
occur. This is a benign behavioral change; previously there were some
circumstances in which the type `Null?` might occur in the analyzer,
but the type `Null?` behaved the same as `Null` so there was no
user-visible effect. This behavioral change brings the analyzer's
treatment of `Null` into alignment with that of the CFE.
This is the first step in a planned patch series. In follow-up CLs, I
intend to:
- Introduce a public-facing `NullType` for use by clients.
- Change `NullTypeImpl` so that it no longer extends `InterfaceTypeImpl`.
- Add a base class that is common to the analyzer and CFE `NullType`
representations.
Change-Id: I9cea84d8149347bffdee006d544af28c66eba429
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396320
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This CL removes the unnecessary conversion from `TypeStructure` types
to `SharedTypeView` and `SharedTypeSchemaView` and back. By design,
the shared constraint generation method is operating on
`TypeStructure` types and uses the shared procedures named with the
'Internal' suffix to transform those types. In this CL the shared
procedures that are only used in the shared constraint generation
method or in 'Internal' procedures are converted to 'Internal'
themselves, and the corresponding update in the parameters accepted
and returned by those procedures is made.
Part of https://github.com/dart-lang/sdk/issues/54902
Change-Id: Ic8596b342bde7e78093e990fc0f12f705ff6dee1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395962
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
This required improving the implementation of `operator == ` for
function types, to check that the bounds match (after performing
appropriate substitutions). It also required modifiying
`FunctionType.substitute` to apply the substitution to the bounds.
The API for `TypeParameter` was changed slightly, so that it's
possible to distinguish between an explicit bound of `Object?` an an
implicit one. This allows `FunctionType.toString()` to avoid
outputting `extends Object?` next to a type parameter that has an
implicit bound.
Change-Id: Iad31a44a1f87ca0cd830b8c802495b7ce2c1caab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396141
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The new formatter supports opting a region of code out from being
formatted. I'm applying this marker to all of the multitests since
those tests are often very sensitive to formatting and easily broken.
This way, anyone touching a multitest (including me when I reformat
the tests) doesn't have to remember to not run the formatter on it.
Change-Id: I34831719cd35e669b49e02a0d00c32b44068a34e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396103
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Adds new names:
- Globals for static field initialization flags are named as
"$memberName initialized".
- Globals for static field values are named as "$memberName".
- Static field initialization functions are named as "$memberName
initializer".
Also documents fields of `Globals` and removes unused field
`_globalInitializers`.
Change-Id: Id54c6e679b2d028917e86184e2913bb51e6b5a97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
The new formatter supports opting a region of code out from being
formatted. I'm applying this marker to all of the multitests since
those tests are often very sensitive to formatting and easily broken.
This way, anyone touching a multitest (including me when I reformat
the tests) doesn't have to remember to not run the formatter on it.
Change-Id: Idb467e105e7ca67c8473c1ee2d2549f7c628661f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396180
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
The Iterables have been separated and specialized.
The `keys` Iterable specialized so that the `contains` method uses the Map's `containsKey` method. This is required for correctness and usually much faster that the linear scan of `Iterable.contains`.
The default `MapBase.entries` maps over the keys and does lookups. It is faster to scan the data like `get keys` and `get values`.
Issue: #52909
Change-Id: Id3400c3efd8e657c74b41b3fce71e0713dc790bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389266
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
The new formatter supports opting a region of code out from being
formatted. I'm applying this marker to all of the multitests since
those tests are often very sensitive to formatting and easily broken.
This way, anyone touching a multitest (including me when I reformat
the tests) doesn't have to remember to not run the formatter on it.
Change-Id: I3d6346d31581772dc8e1701594bf9d919f28db7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396104
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
The new formatter supports opting a region of code out from being
formatted. I'm applying this marker to all of the multitests since
those tests are often very sensitive to formatting and easily broken.
This way, anyone touching a multitest (including me when I reformat
the tests) doesn't have to remember to not run the formatter on it.
Change-Id: I06928e08530ad658affd23e594702cff658d8035
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396181
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Prior to this fix, the "processedMembers" field on the ResolutionWorldBuilder was getting used as the signal that a member was active and therefore any conditional uses dependent on it should be active.
In some cases the following would occur:
1) The listener gets a signal a member is active. It checks if there are any conditional uses for that member and sees none.
2) A conditional use is registered and the member is not indicated as active yet so the use is stored as pending in ResolutionEnqueuerListener.
3) "processedMembers" in ResolutionWorldBuilder is updated for a member that would mark the conditional use active. This doesn't trigger a check of the pending conditional uses.
If the enqueues happen in this order (which is not always the case), the conditional impact will not be marked active and the field will be erroneously tree shaken.
The solution here is to remove step 3 and add an analogous "usedMembers" update in step 1. Step 1 will always occur before step 2 so the conditional impact ledger and the usedMembers ledger will always stay in sync.
Change-Id: Ib732a4fe5dcc8fc7cbe9a6d37e1c239e287595ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395740
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Generic function types have the following special behaviors:
- Their implementations of `hashCode` and `==` take care to ensure
that if two generic types differ only in the names of their type
parameters (i.e. they are alpha-equivalent), they will compare equal
and have the same hash code. For example, `T Function<T>()` and `U
Function<U>()` represent the same type. This logic takes advantage
of `Type.substitute` and `Type.gatherUsedIdentifiers`, added in
recent CLs.
- When parsing a generic function type, references to type formals can
appear in the return type or parameter types. E.g. in the function
type `T Function<T>()`, the return type `T` refers to the type
formal `T` declared by the function type. It doesn't refer to a `T`
declared elsewhere. To make this possible, the parameter
`typeFormalScope` has been added to `Type.materialize`; this carries
the meaning of type formals through the recursive process of
transforming a `_PreType` into a corresponding `Type`.
In a follow-up CL, I will use this new support to unit test the
generic function type logic that's recently been added to
`TypeConstraintGenerator` (see
https://dart-review.googlesource.com/c/sdk/+/393860).
Change-Id: Ib5e392f844990185b2602d22809eac5599505aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395687
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The `_PreType` class (and its subclasses) mirrors the `Type` class,
except that it represents types in a more raw form, before identifiers
have been resolved to their associated meanings. For example, the
`_PreType` representing `int` is a `_PrePrimaryType` whose `typeName`
field is the string `int`, whereas the `Type` representing `int` is a
`PrimaryType` whose `nameInfo` field points to the `TypeNameInfo`
object representing the class `int`.
Parsing of `Type` objects is now a two-step process: the string is
first converted to a `_PreType`, and then the `_PreType` is
materialized into a `Type` by looking up each identifier in it in the
`TypeRegistry`.
This will be needed in a follow-up CL that introduces support for
generic function types, to support the possiblity that a generic
function type's return type refers to one of its type parameters
(e.g. `List<T> Function<T>()`). The reason this is will be needed is
because the meaning of the return type (`List<T>`) can't be determined
until the `TypeParameter` object representing the type parameter `T`
has been created.
Change-Id: I9f4a73bdc0f38380518a9c39db8c788234adb806
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395686
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This method will be used by a follow-up CL that adds support for
generic functions, since the implementation of `==` and `hashCode` for
generic functions needs to perform substitutions in order to recognize
that alpha-equivalent types (such as `T Function<T>()` and `U
Function<U>`) are equal, and those substitutions need to avoid name
collisions with identifier names that already appear in the type.
Change-Id: Ifd237a9842791f440e285d89e9d80b898e996411
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395685
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
I found a number of places where we need to access `variable3`, so
it might be convenient to have a common interface that provides it.
Still, there are many places where we want to know that this is
specifically `GetterElement`, to separate interfaces for them are
also useful.
Change-Id: Ib671dc3bdb9a04a022fd74921f8ccedcdba79643
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395701
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This method will be used by a follow-up CL that adds support for
generic functions, since the implementation of `==` and `hashCode` for
generic functions needs to perform substitutions in order to recognize
that alpha-equivalent types (such as `T Function<T>()` and `U
Function<U>`) are equal.
Change-Id: If641c4d0ae48708abf3701853014dc52dfc559c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395684
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Previously, the `hashCode` and `==` logic for the `Type` hierarchy
used a short-cut: convert the type to a string and then hash or
equality-check the result.
However, that trick won't work for generic function types (which I
intend to implement in a follow-up CL), because generic function types
that are alpha-equivalent (i.e. equivalent except for the names of
type formals) need to be considered equal. So, as preparation for
supporting generic function types, this change adds full
implementations of `hashCode` and `==` for all the classes in the
`Type` hierarchy.
Change-Id: I8312d22cabaeb8c38cd58da80acdb3f068ee5c2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395620
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Simplify the VM-specific `scan` function that assumes an instruction
called `Utf8ScanInstr` and scans the input in chunks to be able to use
the instruction. Instead scan the whole input in one loop.
Change-Id: I9c796e0728e46687653b623effb214ebc93cc01c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395960
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>