We use an extension getter instead of an instance getter because
it doesn't conflict with any potential existing or future enums
which want an element named `name`.
Keeping the namespace for enum elements open is a priority.
We currently only reserve `index` and `values`.
BUG: https://github.com/dart-lang/language/issues/1511
Fixes language issue #1511, which is a long-standing request,
and should replace a number of alternative implementations
which are based on parsing the `toString()`.
This version has two fields on the shared superclass, the index
and private name, and has a separate `toString` for each `enum` class
which hard-codes that enum's class name.
An earlier version had both `"name"` and `"ClassName.name"` as fields
to be able to reuse the same `toString` method on all enum classes,
but that cost too much for JS compiled code.
Even having just `ClassName.` as a field and then combining inside
`toString` requires more code to create the enum instances.
Instead this version hardcodes the `ClassName.` string once
in the `toString` method, which means each enum class has its own
toString (which can *potentially* be tree-shaken then.)
This still tree-shakes slightly worse than the previous implementation
where every enum class had its own `index` and `_name` fields
independent of each other, which could then be tree-shaken independently.
However, the `index` was already made an interface member with the
addition of the `Enum` interface, so code which accesses `.index`
on something of the `Enum` supertype could prevent tree-shaking of
all enum classes' `index` fields.
Likewise any general access to the "name" of an enum would necessarily
do the same for the name.
This CL makes up for some of that by sharing more implementation
between enum classes.
DartVM AOT CodeSize impact: ~0.15% regression on gallery (little less on big g3 app)
TEST= New tests added to enum_test.dart
Change-Id: Id25334e6c987f470f558de3c141d0e3ff542b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210480
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Previously, the FfiCode constructor allowed the error type to be
overridden, but no use of that constructor actually took advantage of
it.
Hardcoding the type of all FFI error codes makes the implementation of
error codes more uniform, which helps pave the way for code
generation.
If in the future, we decide that we actually need some FFI error codes
to have different error types than others, we can always add the
functionality back in.
Change-Id: I5061281089aeba0185fd8ebaa08a82482e91f2ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214070
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
* Fix regression (https://dart-review.googlesource.com/c/sdk/+/214040).
* Add tests for invalid configurations with and without named configs.
* Add a custom test matrix for testing.
Change-Id: If169571c3163c5f4da1d3d989a2fcff6dc0a7d97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214044
Commit-Queue: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
Auto-Submit: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
CFE transformation to add a function body for external fields,
getters, and setters, routing to the relevant js_util
getProperty and setProperty optimized calls.
Change-Id: Ia3d0f05fda50f20d217c0a67e0fd636bb774000b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213600
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Instead getDisplayString() should be used.
Change-Id: I1c988bc9d193398aadbb32620e01f11ea3e353d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213900
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
* Fail test.py if an invalid named configuration is used.
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-product-arm64c-try
Change-Id: Ib700511a639ee39fd58441dd6fee8bd6dad8c2e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214040
Reviewed-by: William Hesse <whesse@google.com>
Fixes https://github.com/dart-lang/sdk/issues/47211
Much of this change is about decision-making based on the _type_ of the
function in a FunctionReference, or the receiver of that function, in the
case of prefixed identifiers or property access.
Previously, there was a rule that only direct references to functions
(top-level, local, and method) could be torn off and type-instantiated.
That rule has been reversed (#1812), so a lot of unraveling has to be
done here.
`e.call<...>` is now legal for _any_ generic function-typed expression
`e`, which certainly may be an expression without a staticElement.
Additionally, `e<...>` is now legal for _any_ generic function-typed
expression `e`.
Because we no longer resolve PropertyAccess piecemeal, we no longer
report UNDEFINED_IDENTIFIER or UNDEFINED_PREFIXED_ELEMENT etc before
deciding to check if a tearoff is being made on a function-typed
element. The unfortunate side-effect here is some redundant
error-reporting. :( I've left TODOs.
Change-Id: I62106332e39d528cbd7cdfa5ec831dc56b394b52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
In many files, there is a redundancy in importing
import 'package:compiler/src/common.dart'
and
import 'package:compiler/src/diagnostics/diagnostic_listener.dart'
I chose to remove the latter import.
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: Ia6c871080bf2d7c637694a4fe5cb1b84e540b789
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213851
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
- Use `{}` syntax for Maps and Sets
- Remove type arguments on right side of initializations with same
type arguments.
- A few cases of replacing conditional code with `??`/`??=`.
Change-Id: I1b58a109b1f8ea8458f37a2de256ffb3dc9956b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213853
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
The error code text is:
The setter '{0}' is private and can't be accessed outside of the
library that declares it.
So when instantiating this error we should only provide a single
argument. Previously we were providing a second argument that was the
name of the type.
Change-Id: I952dec86f079b9e17e071d37895c3b38c715cf4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213826
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Previously, if a CFE error contained a placeholder (such as
`#string`), that wasn't converted to the equivalent analyzer
placeholder, which meant that analyzer error reporting logic needed to
know whether the error being reported came from the CFE or the
analyzer in order to report the error correctly, otherwise the
placeholder text would just show up verbatim in the analyzer output.
Change-Id: If875de3a1a80048700b0edf458377c5fc87a15d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213281
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
The hint code text is:
The declaration '{0}' is annotated with 'visibleForOverriding'. As
'{0}' is not an interface member that could be overriden, the
annotation is meaningless.
So when instantiating this error we should only provide a single
argument. Previously we were providing a second argument that was the
name of the annotation; this is unnecessary because the error message
already mentions the annotation name ('visibleForOverriding').
Change-Id: I022af6914668ad6232005237619b3ab9a5d7a589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213825
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
It was incorrectly marked as having them. Attempting to navigate to docs
opens the correct page but there's no docs to open to so it leaves the
page scrolled to the top.
Change-Id: I862fa215ee59e8aa1200a7e33186e91528b8ef19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213840
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Very often there were two imports of the same URI, one of which also
had a `show` combinator. I opted to remove the other one.
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I1263c892f94f0645fda6dee371dfc1fcddcd2344
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213846
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
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>
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>
And by storing the list of child names in a folder we can implement
Folder.getChildren() more efficiently.
Bug: https://github.com/dart-lang/sdk/issues/47220
Change-Id: I893dffd6ada4095b8580ec5d469142478f57f284
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Expression compiler worker tests sometimes reach the timeout limit
on CI machines, split them into two batches.
Closes: https://github.com/dart-lang/sdk/issues/45484
Change-Id: I502de5d768f29be862e593379e3a906ec6c21eb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213734
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
This tests how the CFE handles loading dills with the dart2js
late lowering.
The currently fails because the fields have changed type and
assignability, as seen from the CFE perspective.
Change-Id: I2229db29144538f0cf5c2ea88c4453c58032d4b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213768
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Also:
- fix order of arguments to HBoundsCheck
Change-Id: I4dbcca67dd89f3048a22315d8db2fa862d810774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213620
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This hint message doesn't take any arguments.
Change-Id: Idc2546901b3dcbbbb45356628028f1ac08d71c7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213730
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This error message was previously reported by the analyzer's parser,
which presumably supplied an argument describing the modifier. It is
now reported by the shared parser, which doesn't supply any additional
information. As a result, the error message was showing up for the
user as "The modifier '{0}' can't be applied to the body of a setter."
(with a literal `{0}` visible to the user).
Changed the error message text to match what the CFE reports. There's
no real need for the message to describe the modifier since the error
message location is the modifier itself.
Change-Id: I538d49c1b693fe6cfb190f584bb5c9ab5cd3cf39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213732
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
These error messages don't take any arguments.
Change-Id: I1818dea02801b3f14f2db0c74841071d8457365a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213728
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This error message doesn't take any arguments.
Change-Id: I12cfe2a079eb3c6f81976e1ce451ce6ab6d0c47a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213731
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The error message text is:
Generic function types can't be used as type parameter bounds
And the correction message is:
Try making the free variable in the function type part of the
larger declaration signature
There are no placeholders in these messages to accept arguments, and
there's really no need for any (since the location of the error is the
offending type), so just remove the argument.
Change-Id: I0ea653d7085782f924c63fbdb0e19ac66f04808a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213700
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This error message doesn't take any arguments.
Change-Id: I5ff2e43c6d6877189ad8cf7cefded72b4867a309
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213727
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The message for this error code doesn't accept any arguments, so
there's no reason for the test to provide any.
Change-Id: I6306cead7865704c9074dd0dc2a1bc1aacaeda16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213724
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Some of the error messages reported by TypePropertyResolver.resolve
require arguments, others don't; this change ensures that we pass
arguments only when they're needed. This should pave the way for
adding assertions to make sure the proper number of arguments are
supplied when instantiating an error message.
Change-Id: Ic94a4ff7ee2f7845a693b91f8a9231570e0cf4c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213723
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
None of the error codes passed to this method require arguments, so if
this method reports an error, it shouldn't supply any arguments.
Change-Id: Iadcf2652bd46420944cbdffcc2e69415c07f00fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213725
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Change-Id: Ic029cf3c823f0b226d41e75513f28632bde52194
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213729
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
INVALID_USE_OF_NULL_VALUE doesn't take any arguments, so we shouldn't
supply any.
Change-Id: I2b78277d754a5d009800927a50cff20c771c162f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213726
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This CL removes async markers where await wasn't used.
In a few cases this also meant the ability to make the procedure not
return a future at all.
Also - at least on the VM with my benchmark run on my PC - returning
new Future.value(whatever) in a non-async procedure is faster than
returning whatever in an async procedure.
TEST=CI and existing tests.
Change-Id: I4ba888313c87de76bb0ca02c19eb1ab45f168a85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213480
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
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>
Allows for tooling (e.g., DAP) to spawn their own DDS instance without
having to disable the CLI.
Fixes https://github.com/dart-lang/sdk/issues/47059
TEST=pkg/dartdev/test/commands/run_test.dart
Change-Id: Ie9a4832d424edae67f32560399d3b0a6ca9f1dc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213660
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This improves discovery, refactoring, etc.
I did not change any locations which would have required interpolation,
or tests which refer to a String immediately nearby (in tests).
Change-Id: I8479fd7822713e878e56fdf5ec35969492049333
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Change-Id: If3e7d74af72c4d3c4e533d2c3dcd880c4f2b5bf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213622
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
In legacy code `int v` was implicitly `int|Null v`, so `v is int` could
be useful (although probably should be `v != null` then). In null safe
code, we cannot have `Null`, so we can report a hint.
Change-Id: I60dc0791c6b8346d924fd13b1d2ce3fcceb22d32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190360
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Saw in crash log:
StateError: Bad state: No type: void
at ExpressionExtension.typeOrThrow (extensions.dart:89)
at MakeReturnTypeNullable.compute (make_return_type_nullable.dart:55)
Change-Id: Id985d7a2bb26fe9e494f3a36dc0b15196c6de463
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213412
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1. Make unwrapException pure. This allows it to be removed if the
exception is unused, and ensures that the catch does not unnecessarily
invalidate locations. This is helpful since, by itself, this change
causes some test failures due to the load elimination bug (#47166).
2. Invalidate locations on entry to catch and finally blocks. This is
a conservative fix for #47166.
Bug: 47166
Change-Id: If3b4113b538978095d59814c16bd8375bbd70696
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213414
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
This code is simpler and conceivably reduces memory usage.
Change-Id: Ic20a3ec05b60c557d829fc52a79589d6445e062d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213413
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>