commit | 3fead79c14ba99fd1f86a85922e351439fc9394f | [log] [tgz] |
---|---|---|
author | Paul Berry <paulberry@google.com> | Thu Dec 07 23:40:27 2023 +0000 |
committer | dart-internal-monorepo <dart-internal-monorepo@dart-ci-internal.iam.gserviceaccount.com> | Thu Dec 07 15:42:12 2023 -0800 |
tree | 284359a292f80bb245717f127192f2b8679de694 | |
parent | 54e9f6a8e4edb6dee8d3c5a487a427293432639e [diff] |
Allow "field promotion" to apply to abstract getters. A quirk of analyzer and CFE implementations is that they resolve property gets such as `foo.bar` to specific field or getter declarations that may be not be directly defined on the target type; for example if `foo` has type `B`, and `B` extends `A`, and `A` contains a field called `bar`, then `foo.bar` is considered to refer to `A.bar`, for example: class A { int? bar; } class B extends A {} f(B foo) { print(foo.bar); // Resolved to `A.bar`. } This is in contrast with the language specification, which makes a clean distinction between class _declarations_ and the _interfaces_ implied by those declarations. While a class declaration can contain (among other things) both getters and fields, which might be concrete or abstract, an interface doesn't distinguish between getters and fields, and is inherently abstract. The advantage of the analyzer/CFE approach is that it allows more intuitive error messages and "go to definition" behavior, which benefits users. But it has some ill-defined corner cases involving complex class hierarchies, because not every property access can be resolved to a unique declaration (sometimes a getter is multiply inherited from multiple interfaces, for example). The language spec approach has the advantage of being well-defined and consistent even in situations involving complex class hierarchies. When I initially implemented field promotion, I took advantage of this quirk of the analyzer and CFE implementations, so that I could make property gets that refer to field declarations promotable, while keeping property gets that refer to abstract getter declarations non-promotable. This caused unpredictable behaviors in the ill-defined corner cases. It also meant that in certain rare cases, a property access might not be promoted even when it would be sound to do so (e.g. a property access might refer to a private abstract getter declaration, but the only concrete _implementation_ of that abstract getter was a final field). This CL changes the rule for promotability so that any get of a private property is considered promotable, provided that the containing library doesn't contain any concrete getters, non-final fields, or external fields with the same name. It no longer matters whether the private property refers to a field or a getter. This rule is simpler than the old rule, restores the spec's clean distinction between class declarations and interfaces, and allows more promotions without sacrificing soundness. For additional details please see the breaking change announcement at https://github.com/dart-lang/sdk/issues/54056, as well as the original change proposal at https://github.com/dart-lang/language/issues/3328. Fixes https://github.com/dart-lang/sdk/issues/54056. Fixes https://github.com/dart-lang/language/issues/3328. Change-Id: I38ffcb9ecce8bccb93b1b2586a1222a0fb1005a7 Bug: https://github.com/dart-lang/sdk/issues/54056 Bug: https://github.com/dart-lang/language/issues/3328 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337609 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> https://dart.googlesource.com/sdk/+/004f564f40cee1deba2593ef3fd6d197482b27c1
Monorepo is:
With depot_tools installed and on your path, create a directory for your monorepo checkout and run these commands to create a gclient solution in that directory:
mkdir monorepo cd monorepo gclient config --unmanaged https://dart.googlesource.com/monorepo gclient sync -D
This gives you a checkout in the monorepo directory that contains:
monorepo/ DEPS - the DEPS used for this gclient checkout commits.json - the pinned commits for Dart, flutter/engine, and flutter/flutter tools/ - scripts used to create monorepo DEPS engine/src/ - the flutter/buildroot repo flutter/ - the flutter/engine repo out/ - the build directory, where Flutter engine builds are created third_party/ - Flutter dependencies checked out by DEPS dart/ - the Dart SDK checkout. third_party - Dart dependencies, also used by Flutter flutter/ - the flutter/flutter repo
Flutter's instructions for building the engine are at Compiling the engine
They can be followed closely, with a few changes:
goma_ctl ensure_start
is sufficient.Example build commands that work on linux:
MONOREPO_PATH=$PWD if [[ ! $PATH =~ (^|:)$MONOREPO_PATH/flutter/bin(:|$) ]]; then PATH=$MONOREPO_PATH/flutter/bin:$PATH fi export GOMA_DIR=$(dirname $(command -v gclient))/.cipd_bin goma_ctl ensure_start pushd engine/src flutter/tools/gn --goma --no-prebuilt-dart-sdk --unoptimized --full-dart-sdk autoninja -C out/host_debug_unopt popd
The Flutter commands used to build and run apps will use the locally built Flutter engine and Dart SDK, instead of the one downloaded by the Flutter tool, if the --local-engine
option is provided.
For example, to build and run the Flutter spinning square sample on the web platform,
MONOREPO_PATH=$PWD cd flutter/examples/layers flutter --local-engine=host_debug_unopt \ -d chrome run widgets/spinning_square.dart cd $MONOREPO_PATH
To build for desktop, specify the desktop platform device in flutter run
as -d macos
or -d linux
or -d windows
. You may also need to run the command
flutter create --platforms=windows,macos,linux
on existing apps, such as sample apps. New apps created with flutter create
already include these support files. Details of desktop support are at Desktop Support for Flutter
Tests in the Flutter source tree can be run with the flutter test
command, run in the directory of a package containing tests. For example:
MONOREPO_PATH=$PWD cd flutter/packages/flutter flutter test --local-engine=host_debug_unopt cd $MONOREPO_PATH
Please file an issue or email the dart-engprod team with any problems with or questions about using monorepo.
We will update this documentation to address them.
flutter
commands may download the engine and Dart SDK files for the configured channel, even though they will be using the local engine and its SDK.gclient sync
needs to be run in an administrator session, because some installed dependencies create symlinks.