Eventually, these hints should probably be moved over to warnings. But
for now, this makes it possible to write static error language tests
that validate that analyzer produces unreachable case warnings/hints
where expected.
Also updated the patterns/ and switch/ tests now that those errors must
be expected by the test.
Change-Id: If1fb92602c4bde2819b9eec73598033009054947
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291967
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
In Safari, the prototype of a SpeechRecognition object returns a
webkitSpeechRecognition prototype. This name is different than the
one in the @Native annotation, so dart2js fails to recognize it. We
should it to the annotation so we properly intercept it.
CoreLibraryReviewExempt: Changing bindings of dart:html, no change to API.
Change-Id: Ic533e1208dd28e521403998e43009e0f651e2dfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291961
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
This code is opted in to the latest language version but was not ever migrated.
It could possibly be just deleted, as it hasn't been runnable for some time, but I have no idea really.
Change-Id: I7ccda121dcd56ed9388b48c70e3b3c0b2d087e47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292042
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
The precedence-based pattern parser can understand a unary pattern
inside another unary pattern (e.g. `_ as int as num`) or a relational
pattern inside a unary pattern (e.g. `> 1?`), but the specification
prohibits these constructions because they're difficult to read and
not very useful.
This change updates the implementation to match the spec, by producing
the appropriate error. The offset and length of the error cover the
inner pattern, so it should be easy to construct an analysis server
quick fix that inserts the necessary parentheses.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I33e74d6d1f863e7162851d26fefbacd4fd17277c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Add a simple (but incorrect) implementation that avoids crashing
the compiler when encountering a `RecordType` in canary mode.
This is a temporary workaround to unblock landing changes that
add the use of record types to the SDK.
Fixes: https://github.com/dart-lang/sdk/issues/51904
Change-Id: Ibaa88f06bf42e7be3a1853be3fb43c55c6fe8e66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292203
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
A `@reopen` annotation is invalid when it annotates a declaration which
does not reopen anything.
Fixes https://github.com/dart-lang/sdk/issues/51592
Also cleaned up some code around reporting other invalid annotations.
Change-Id: I5add39cf2ef553a3441d39dfc47bcd1ffdbeb8ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292140
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This will save me a lot of time because I keep forgetting where the
status file is.
Change-Id: I3ab6ad59f66c4e84515bad3a6b7689b6b47ecddf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292283
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Adds a `--no-pub` flag to those commands
Bug: https://github.com/dart-lang/sdk/issues/50422
Change-Id: I949605c4ebb4c609eb19159625958317e54523a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291500
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Change-Id: Iabf6c5d53ef6048865cef64b73d3c6e2e2db370d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292121
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The logic for parsing types has special disambiguation rules for
deciding whether a trailing `?` should be included in the type, based
on what token(s) follow the `?`. In the case where the token that
follows the `?` is `when`, we need to look further ahead to
disambiguate, to distinguish `PATTERN as T? when guard` from something
like `EXPRESSION is T ? when : otherwise`.
(Note: an alternative implementation would be to disambiguate based on
whether we're parsing a pattern or an expression. But in the future I
want to move toward an architecture where expression parsing and
pattern parsing are combined, so that if the parser makes the wrong
decision about whether it's looking at a pattern or an expression,
error recovery will do a better job. So I'm disambiguating based
solely on what follows the `?`.)
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Idbc780b7b54fecc7fd01cae868c34771564dd804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292282
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
The new version optimizes slightly better and much faster.
Change-Id: Icbd8cd01f149c609043572bdadd42be2afd6ac54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292301
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
When patterns are enabled, the case expression is not an inferred
constant context.
Closes#51898
Change-Id: I6b5a68b8de587c53a329756b6ce7caa6b9235fef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292081
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This improves the precision of the Wasm types for Dart function types
in instance method signatures.
It could in principle also improve the precision of the receiver
parameter from the LUB of the representation types to the LUB of the
actual structs for the classes implementing the member. However,
if at a call site the receiver parameter type is more precise than the
representation type of the receiver, the call site will need to cast
the receiver to the more precise type. This gives rise to more casts
in practice than the ones saved inside the methods by the more precise
receiver parameter type. For this reason, the receiver parameter type
is kept at the LUB of the representation types of the classes
implementing the member.
This change is also a stepping stone towards not having `ClassInfo`
for the special Wasm types.
CoreLibraryReviewExempt: Only affects Wasm-specific libraries.
Change-Id: I81ca5aa1107f1c04ed7729a758e983698492a106
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288400
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Use the `TrustedGetRuntimeType` interface to mark implementation
classes that have a `get runtimeType` that should be used for
reporting the types of instances in errors and `Record.runtimeType`.
Streamline the various more general `get runtimeType` implementations
by specializing them to the context. By explictly implementing
`Closure.runtimeType` we avoid the need to test for closures in the
'ordinary' object path. This should help the Flutter pattern of
testing `a.runtimeType == b.runtimeType`.
Change-Id: Ib49a6d89ff23e752beed8753aafceff40457433d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291741
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
We encode line/column in a single 64-bit integer and derive offset from this using the lineStarts stored on the kernel Source object.
Saves 90-100MB of memory within the emitter phase on a large program. Most of that is from the smaller deserialized SourceLocation objects but some memory is also saved due to the smaller output size from the compact serial representation. The input to the emitter phase is ~14MB smaller (with the savings split across multiple codegen shards).
Change-Id: Ic71231fb43fc746293b6f6f77e0ee2c3b17742cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291900
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
In particular, this fixes some type tests involving records.
`(1, true) as FutureOr<(int, bool)>` was failing because the Rti for the
record literal was _Record_2 rather than +(int, bool). We want to avoid
constructing the full record Rti, so instead we can have the specializer
for FutureOr directly delegate to its union components.
Fixes: #51910
Change-Id: I3716882aab0a519ab35803d87fabe570b7e27655
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292242
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
It is still an error to have duplicate keys.
Change-Id: Id86fa7b50c3620540f4bef0399f5f70316848662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292125
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
This is another reland of 4f8333e80e.
Third time is the charm.
CoreLibraryReviewExempt: Reland of accepted CL.
Change-Id: I4ea8326af91c168b044d252162571d3fe697e4b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289826
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This allows for users to dismiss a notification without taking any action (something that VS Code / LSP allows for but this API did not).
Change-Id: Icf384008cfcfde6f150c63d3f2889e81e79d1dc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
- Mostly restores the pre-kernel behavior, except that actual arguments are not passed to the NoSuchMethodError.
- Instead of a vague error message, the call site whose target is missing is now part of the stack trace and the name/kind of the missing target is part of the exception message.
- If the missing target is on a branch not taken, things properly succeed.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/37517
Bug: https://github.com/flutter/flutter/issues/122626
Change-Id: Ic3d5a386caa8d1627d8452a5601bc728ad519987
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291055
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Change-Id: I068573a3534816b301fde8628d8f15f8c0286898
Tested: not really tested, should be a noop.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292022
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
The listener API for variable patterns is split into three separate
functions, to handle the three separate behaviors:
- `handleAssignedVariablePattern` for variable names appearing in an
assignment context (these assign to an existing variable upon a
successful match).
- `handleDeclaredVariablePattern` for variable declarations appearing
in a declaration or matching context (these cause a new variable
name to come into scope).
- `handleWildcardPattern` for wildcards in any context (these don't
capture the matched value).
Also, responsibility is shifted to the parser for reporting the
following error conditions:
- VariablePatternKeywordInDeclarationContext (e.g.
`var (var x) = ...;`)
- PatternAssignmentDeclaresVariable (e.g. `[x, var y] = ...;`)
Previously these errors were detected by the implementations, and
weren't fully covering all possible error scenarios.
In the case of VariablePatternKeywordInDeclarationContext, the
listener method `handleDeclaredVariablePattern` is called instead of
`handleAssignedVariablePattern`. This ensures that no tokens are
dropped from the analyzer AST. The CFE uses the `inAssignmentPattern`
argument of `handleDeclaredVariablePattern` to distinguish this error
recovery case from a legitimate declared variable pattern.
Fixes#51868.
Bug: https://github.com/dart-lang/sdk/issues/51868
Change-Id: I28ec679b73d64033166721c6460be35f15e23171
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291583
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>