Adds a flag `--generate-prototype-events` to the dart:html generation
scripts, which causes a `prototype_events.dart` file to be generated
with EventStreamProviders and extensions for all events generated
in legacy dart:html. The generated file can be copied and pasted into `html_events.dart` to be used in the new dart:html prototype.
The script `prototype_htmleventgenerator.py` reuses as much common functionality as possible from the `htmleventgenerator.py`.
There were many edge cases to consider, like:
- de-conflicting names with different event types (e.g. ProgressEvent onError vs SpeechRecognitionErrorEvent onError)
- hiding deprecated types that don't appear in the Web IDL and haven't been needed in the glue code prototype yet
- renaming extension on-types that have been renamed from the Web IDL
- hiding custom events, which then need to be added to the prototype by hand
- prefixing some events with the correct web library
Change-Id: I6ab944d74ede6d8a2178bbf9aa580a6ab7d67a77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259063
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Previously the AstBuilder used a temporary ParenthesizedExpression
node for this purpose. Using a custom data structure belonging to the
AstBuilder is less hacky, and paves the way for supporting more
complex conditions (such as those that arise in the `if-case`
construct in the "patterns" feature).
Change-Id: I623cf484d400aef44e835ee95a55903d80aa11a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259105
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This issue (Migration tool null safety detection fails when tests use
path imports) was reported in December of 2020 and I can't reproduce
it. I believe there have been changes in analyzer package resolution
since then, aimed precisely at helping users who use this sort of
improper path import. So it is likely that those changes fixed this
bug.
I'm adding a test case to ensure that the bug isn't accidentally
un-fixed by future changes.
Bug: https://github.com/dart-lang/sdk/issues/44394
Change-Id: I81490e545aa41196c3c69bc4d74cd481079d59ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259200
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This introduces a MemberName abstraction that supports the late
computation of member names, taking privacy and synthesized names
of unnamed extensions into account. With this feature, the unnamed
extension are now more directly handled as having no (known) name
which avoids the clash between the eagerly synthesized named of
unnamed extensions in different parts.
Closes#48765
TEST=existing
Change-Id: I62c00ace017141ecbc61eeecb275d0211f341c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258800
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Default parameter values are implemented in dart2wasm via caller-side
substitution. When the same parameter has different default values
across different implementations within the same selector, a
special sentinel value is passed by the caller, and the callee
checks for this value and substitutes the actual default value.
Change-Id: I8235145f93c2aee7e9ef603456380253b836fcef
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259040
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
The package 'wasm' was moved to https://github.com/dart-lang/wasm in
063d0ef286.
Some of the tests for this package in pkg/wasm/test were duplicated
(probably with some changes) in tests/lib/wasm, and the commit that
moved the package to the new repo forgot to remove those duplicated
tests. This commit removes them.
Change-Id: I24ecbab99a383319482a2220623449bd516e6528
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258926
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Relatved to https://dart-review.googlesource.com/c/sdk/+/259020
The goal is to avoid the need to update NodeListImpl.
I'm not 100% sure that we can fully achieve this, there is at least
one more place with switch / case.
Change-Id: Ic7468a7b9ded817b3315902cefdeaa7428ec6857
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
I don't believe that we need to implement anything new for these two
protocols to work correctly, and these tests are intended to demonstrate
that that's the case. The tests aren't intended to be exhaustive, but if
there are areas that you think should be tested, or aspects of the
protocols that you think might be impacted by records, please let me
know.
Change-Id: Id37fa4764b5d1d69cb7fb31f1a035e517043e96a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
This change refactors the logic for detecting overlapping and missing
variable patterns so that it can be invoked prior to the rest of type
analysis, rather than during it. In addition separating concerns
nicely (since no types are involved in these checks), I believe this
will facilitate integration with the analyzer and front end, by
allowing them to detect these errors and find the unique set of
variables defined by a pattern, at the time they are resolving
identifiers to their corresponding declarations.
Change-Id: I40879fca46d39e78a60813db007983e57a3aec31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259021
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
When using `Uri.parse` or `Uri(path:..)`, a `\` is treated as, and converted to, a `/`.
This avoids a particular problematic difference in behavior between Dart and the browser's `URL` functionality. There are still examples where the two differ in interpretation of the same code, but in those cases, the Dart `Uri` will most likely end up without a host name, which should be easily detected.
Change-Id: I798df6c3c27c6d64fb9fc8dc30d90b06ba5a9004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258120
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
This currently isn't working, and I haven't yet figured out why. At this
point I thought it would be faster to ask than to keep guessing.
The problem is that the server is not getting initialized correctly.
There's probably something I don't understand about the way LSP clients
in general (and tests in particular) are expected to operate. I looked
at some of the other tests, but the ones that I looked at don't appear
to be following a common pattern.
Change-Id: I886a210f7b98a14de2f1bc53c2a499cc3462d6dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255100
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
I've begun prototyping what it might look like to integrate the
current shared type analysis functionality with the analyzer and CFE,
and I've discovered some API improvements that are needed:
- The shared logic now handles the possibility that switch cases that
share a body have been merged prior to type analysis (because the
CFE merges them during parsing), in addition to the pre-existing
functionality which assumed that switch case merging had to be done
in the shared logic.
- The shared logic now returns several pieces of information as the
result of a call to `analyzeSwitchStatement`: whether the switch
statement had a `default` clause, whether it was exhaustive, whether
the last case body terminates, and the type of the scrutinee. These
are all needed by the CFE.
- The shared logic now allows `TypeAnalyzer.errors` to be `null`,
indicating that no errors should be reported. This reflects how
errors are suppressed during top level inference in the CFE.
- If a switch case lacks a `when` clause, this is reported by calling
`handleNoWhen` rather than passing a boolean to `handleCaseHead`.
- The shared logic now reports the appropriate error when a case
constant doesn't properly match the scrutinee's static type.
- Information about case labels is now delivered to flow analysis via
`switchStatement_endAlternatives` rather than
`switchStatement_beginCase`. This made it possible to rewrite the
shared `analyzeSwitchStatement` method in a way that requires less
bookkeeping, because it no longer has to peek ahead to look for
labels associated with a given case body.
- `TypeAnalyzer.analyzeExpression` is now responsible for
understanding that "no context" and a context of `dynamic` should
both be coalesced to `?`. The analyzer does this (although it's not
100% why), and it's definitely "business logic" that eventually
belongs in the shared type analyzer.
- `TypeAnalyzer.analyzeSwitchExpression` and
`TypeAnalyzer.analyzeSwitchStatement` no longer receive a list of
ExpressionCaseInfo / StatementCaseInfo objects describing the cases;
instead they query for them using a callback. This reduces the
lifetime of the ExpressionCaseInfo / StatementCaseInfo objects. In
the future, when we have record support, we could replace these
objects with records, which would then be passed on the stack,
avoiding any allocations.
- A new hook, `handleSwitchScrutinee`, is called right after visiting
the "scrutinee" expression of a switch expression or switch
statement. This hook is needed by the analyzer to compute
exhaustiveness. In a future CL, I hope to move exhaustiveness
analysis into the shared code as well, which should make this hook
unnecessary.
- `TypeAnalyzer.analyzeSwitchStatement` now reports an error if a
switch case completes normally and pattern support is not enabled.
- The test class `_MiniAstTypeAnalyzer` no longer overrides
`analyzeExpression` to provide a default context type; instead,
every call to `analyzeExpression` that didn't previously provide a
context now provides a context of `?`. Note that not all of these
are correct, but they are close enough for the unit tests we have
today. I plan to fix them in future CLs as I replace this logic
with shared logic.
- The hook `handleVariablePattern` is now always provided with a
static type. Previously, it was only provided with a static type if
this was the first time the variable was bound in the pattern.
Change-Id: I70e3c5468312a9329fcf4ad2e13749a32d2418e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257487
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
* Avoid calling memmove(dst, nullptr, 0) as this is flagged by UBSAN.
* Avoid hitting a bug[1] in the linker: LLD's identical code folding
(ICF) happens to replace RecordCoverageInstr::DebugName() with
DispatchTable::LargestSmallOffset() because they happen to contain
the same machine code, ICF fails to accomodate that DebugName also
contains a relocation to constant string. To avoid this we simply
eliminate LargestSmallOffset and replace it with a constant. Same for
OriginElement.
TEST=manually tested previously failing tests
[1]: reported https://github.com/llvm/llvm-project/issues/57693
Change-Id: I38637df6475c7670081b7af0a2de75ca37f6f07c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258801
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
This bypasses the hoisting of record elements in constant record literals.
The created let variables would otherwise interfere with the constant
evaluation.
Closes#49915
Change-Id: Ia70387a0f0c435373dc5fcf5cdd526104db8f394
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258363
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Changes the representation of closures to include a vtable with entry
points for the various ways in which the function can be called.
For each combination of type parameter count and positional parameter
count, the names of named parameters occurring together with that
combination are partitioned into clusters such that any combination of
names that occurs together is contained within a single cluster.
Each combination of type parameter count and positional parameter
count gets a vtable layout for signatures without named parameters,
plus one for each cluster of parameter names belonging to the
combination.
Each vtable layout will have an entry for each number of positional
arguments from 0 up to the maximum number for the signature, followed
by an entry for each (non-empty) combination of argument names from
its cluster that occurs in a function call in the program.
This layout scheme is consistent with function subtyping in the sense
that if signature B is a subtype of signature A, then the Wasm struct
for the vtable layout corresponding to B is a subtype of the Wasm struct for the vtable layout corresponding to A, i.e. the fields in the layout
for A is a prefix of the fields in the layout for B.
Change-Id: I36569be5251cc0cca4373b08c48d37c214478c3c
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256822
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Instead of using top types for the parameters and return of the
implementation function for a function expression or local function,
use precise types and generate a wrapper function with top types that
casts the parameters and calls the implementation function.
This unifies the wrapper function generation with tear-offs, setting
the stage for the upcoming generalization to support type parameters
and optional parameters.
The change also brings some benefits in its own right:
- Arguments to closures are converted once instead of at every use
- Direct calls to local functions avoid the conversion of arguments
Also add source location to closure function names and generally avoid
parentheses in function names, as they are confusing in stack traces.
Change-Id: If83073bb2e2dd17554ffa03fa2596e79d730fb67
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256665
Reviewed-by: Joshua Litt <joshualitt@google.com>