Commit Graph

13891 Commits

Author SHA1 Message Date
Konstantin Shcheglov 63f5b1272b Discover actual dart-sdk/ and bin/ when running tools/test.py
Context: hanging when running new macro tests.
https://dart-review.googlesource.com/c/sdk/+/341483

Change-Id: I59648e47df06b38ec61e8e34e6abe2228a1149f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342381
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-18 19:29:10 +00:00
Konstantin Shcheglov 2261250bea Macro. Implement typesOf()
Change-Id: I25a104c58e6c850a233b51e4ab737ee72bfd1063
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342160
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-15 23:06:10 +00:00
Konstantin Shcheglov b848a72837 Macro. Test isExactly() and resolveType() when using RawTypeAnnotationCode.
Change-Id: I42ade6b9c0bce41ee91309c520ea441e95c4dc86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342089
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 22:32:35 +00:00
pq a00dc1504e remove TypeSystemImpl.strict{Casts|Inference}
Fixes: https://github.com/dart-lang/sdk/issues/53873

Change-Id: I8cb982c8f6549a604c6815cfebbeede27f56b030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-15 22:05:47 +00:00
pq 40e5e46a54 migrate strict{Casts,Inference} from typeSystem
Another angle on removing tracking of `strictCasts` and `strictInference` from the type system, this time threading these configuration values individually to the functions that need them. (In contrast to the solution in https://dart-review.googlesource.com/c/sdk/+/341326).

See: https://github.com/dart-lang/sdk/issues/53873.

Change-Id: I63d73fd81401ac03121831af5e8d4ca43200bb7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341336
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 19:45:09 +00:00
Konstantin Shcheglov 3d24839907 Macro. Support more elements in resolveIdentifier(), parts.
Change-Id: I88c5b15f826113a21869228f66ac4a1ede7a0415
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342084
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 18:55:17 +00:00
Simon Binder 150e61a662 [vm/ffi] Support @Native fields
Allow annotating top-level or static fields with `@Native` to create
fields backed by native memory.
By using the `_addressOf` operator implemented in the VM, these fields
can be implemented in the CFE by replacing them with accessors looking
up the pointer and then using existing methods to load and store the
value.

Closes https://github.com/dart-lang/sdk/issues/50551

TEST=tests/ffi/native_assets/asset_*_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

CoreLibraryReviewExempt: VM & dart2wasm only feature
Change-Id: I61dccc88076723d6a6ba02d7fd848b18e4caf780
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338020
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-12-15 11:20:23 +00:00
Johnni Winther 8ca0aa23ea [cfe] Report error on covariant in extension type methods
Closes #53324

Change-Id: Iff86c4eb7c141f27c64de29459390ac395e1c4ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341487
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-15 09:13:07 +00:00
Konstantin Shcheglov b305954b60 Macro. Support enums introspection.
Only from nodes for now.

Change-Id: I2fe9419590b78b4cf87d1d30587845c362f6129d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341822
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-15 00:44:49 +00:00
Sam Rawlins aad9e57674 Revert "Revert "[analyzer] new warning for nullable '==' parameter type""
This reverts commit 885457e1d3.

[analyzer] new warning for nullable '==' parameter type

This rule checks that a parameter to an `operator ==` implementation has
a non-nullable type.

I intentionally did not enforce, in this rule, that the parameter is
exactly `Object`. It is legal to narrow the parameter type to a
different non-nullable type, like `int`. I can't imagine doing it, but
it seems to be unrelated to whether the type should be nullable or not.

Fixes https://github.com/dart-lang/linter/issues/3441

Replaces https://github.com/dart-lang/linter/pull/3923

Change-Id: Ic0be2bfebaf59b0336e9a3a58e5b7f5359eb8646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-14 23:58:12 +00:00
Sam Rawlins c7cf2c8cb2 analyzer: Improve error message when no unit found
Change-Id: Ib42ddc2a9051900e7ece05f69f0dc942f3bf9f6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341800
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-14 22:05:28 +00:00
Konstantin Shcheglov 0696f66e4d Macro. Introspect extensions, extension types, more functions from elements.
Change-Id: Ib9df35d5e03c00ee58be14ba1df4df0b4c315885
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341623
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-14 21:05:16 +00:00
Konstantin Shcheglov 2b0c848cbe Macro. Use the types of formal parameters of the macro constructor for argument types.
Change-Id: I0570832a4b8c842013e87460e24408d15a42310f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341396
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-14 19:42:17 +00:00
Konstantin Shcheglov 55bd60be32 Macro. Find the declaration to introspect by URI and name, when from elements.
This makes the output more compact.

This also allows to introspect declarations that are otherwise hard
to reference, such as functions. I will add more in following CLs.

Change-Id: I4775beca6aac5e642028b05f40aac31b079ba9de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341391
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-14 02:27:26 +00:00
Konstantin Shcheglov b922ada5c5 Macro. Use sealed TypeAnnotationImpl and its subclasses to avoid 'default'.
Maybe?

Change-Id: I67372e4269a2db5d2426f16a2af3ddd02766fca6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341334
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-13 18:03:57 +00:00
Konstantin Shcheglov 9a452fb98a Macro. Use 'optionalPositionalParameters' for resolveType(), and when build FunctionTypeAnnotationCode.
Change-Id: I4103e95bacc47bd0a97129329a003e0e83393ab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341333
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-13 17:28:57 +00:00
Konstantin Shcheglov 3e4a2813cc Macro. Support for RecordTypeAnnotationCode.
Change-Id: I9c02b6cb2221e213ef225664ceedbcf78f13bd13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341388
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-13 00:52:18 +00:00
Konstantin Shcheglov 706d105007 Macro. Support for resolving OmittedTypeAnnotationCode.
Change-Id: Ida96aae6e2c2e64c4deb00ad029de64b69a2dccc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341386
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 21:02:00 +00:00
pq f3be94a9ca deprecate singelton analysisOptions getter
Change-Id: I2c1e93ef16862b8f5cbe1fe69fd30947cc0a784a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341323
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-12 19:27:18 +00:00
pq b17d4cb14b Fix a few typos
Change-Id: I461ea0c88c257c630577d21bd94c08a3fadb3ade
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341384
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 19:16:13 +00:00
Konstantin Shcheglov 45944662db Update Blaze language version reference.
From https://critique.corp.google.com/cl/590196257

Change-Id: Ic1e89a9449ac9f16e8064e0d6256a56593934dea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341380
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-12-12 19:08:10 +00:00
Daco Harkes 069e617ef4 [analyzer/ffi] Fix Unwrap typed data error messages
Fixes issues reported by:

TEST=pkg/analyzer/test/verify_diagnostics_test.dart

* Fixes error messages on asFunction.
* Fixes validation by introducing Uint8List to mock sdk.
* Removes unused typed_data import in example snippet.
* Fixes error locations in example snippets

Bug: https://github.com/dart-lang/sdk/issues/44589
Change-Id: I82261eea5e55cbafa686865a92131a449a7642f5
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-mac-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340921
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-12 14:32:57 +00:00
Konstantin Shcheglov 4e0260727c Print the package of BasicWorkspace.
So that when we reference it from a file, we have it defined.

Change-Id: I572a4508baab907e26b797ae32ea331a1c4e5036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341103
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 05:53:00 +00:00
Konstantin Shcheglov 8637cd6010 Simplify usual case of a single included path in AnalysisContextCollectionTest.
Change-Id: Ib618a7104ec3e9cb3d4a83f7d0583c2895ffae2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341162
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 05:43:09 +00:00
Sam Rawlins 9ea048bc89 Do not allow void results in record literals
I also privatize all of the "repor"t methods, so the sort makes for a
big diff.

Fixes https://github.com/dart-lang/sdk/issues/52759

Change-Id: I0e7b2602e27ffe2eeab7688787d38ed039895b15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341163
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 03:44:47 +00:00
Konstantin Shcheglov 89d7197b89 Macro. Distinguish named and named required formal parameters in Code.
Change-Id: I18a9a868371ad783bb780faba2be01819112b6e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341161
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 01:34:48 +00:00
Konstantin Shcheglov d156344a08 Macro. Implement inferOmittedType()
Change-Id: I0e2b3ee2eefb7da99b604d552a7909bca1dc9737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341102
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-12 00:54:28 +00:00
pq 12598e6b0f deprecate analysis options sdkVersionConstraint getter
Noteworthy:

* deprecates the `sdkVersionConstraint` getter and updates uses
* migrates tests for sdk contstraints in the absence of a pubspec from context_builder_test to analysis_context_collection_test
* makes `pubPackages` getter broadly visible

Next step: remove the code that sets the `sdkVersionConstraint` in the analysis options object and remove the getter.


Change-Id: I443cdd15ec8d28ac6fa6786e06c1e4b027eee747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341084
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-12-12 00:20:50 +00:00
Daco Harkes 40094c8cfd [vm/ffi] Unwrap typed data in FFI calls
Enables passing inner pointers to typed data in FFI leaf calls.

This works for typed data's in the Dart heap, external typed datas
(constructed from `Pointer.asTypedList`), and typed data views.

Notable implementation details:
1. The Dart signature is used in the Marshaller now. This means it
   needs to keep track of whether there's a pointer argument in the
   signature (`asFunction`) or not (`@Native`).
2. Unwrapping is done in `FfiCallInstr::EmitNativeCode` before moving
   the arguments to their native location. This ensures we can use
   the assembler logic to load the `TypedDataBase::data` field.
3. The `XXXList` user visible classes don't have predefined cids.
   So the implementation uses symbols for comparison.
4. The type checking logic takes `isLeaf` as input to reject typed
   data. This leads to an error message about the type not accepted.
   Alternatively, we could consider adding an error message that
   specifically says the function should be leaf.
5. To cover all calling convention variants, tests are generated with
   up to 20 arguments.

TEST=pkg/analyzer/test/src/diagnostics/ffi_unwrap_typed_data_test.dart
TEST=tests/ffi/unwrap_typeddata_generated_native_test.dart
TEST=tests/ffi/unwrap_typeddata_generated_test.dart
TEST=tests/ffi/vmspecific_static_checks_typeddata_test.dart

Closes: https://github.com/dart-lang/sdk/issues/44589
Change-Id: Ia78f18bf3238d42ac6882929b441f6dc432fcefe
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338620
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-12-12 00:05:02 +00:00
Keerti Parthasarathy 208c99fca3 Revert changes to support multiple packages in PubWorkspace.
The changes caused a regression, caught in https://golem.corp.goog/Revision?repository=dart&revision=107434.

Change-Id: If867769fc9c64765ba967f778e5de10e52a11c42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2023-12-11 22:17:19 +00:00
Konstantin Shcheglov 45f2fff8e5 Macro. Add more types to resolveType(), use in isExact().
Change-Id: I7953ee15be8a756fec53ee140df09dad95d9ad65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341082
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-11 21:46:38 +00:00
Ahmed Ashour d9962e5053 [analyzer] UNNECESSARY_SET_LITERAL to handle multiple expressions
Bug: https://github.com/dart-lang/sdk/issues/50900
Change-Id: Id09e102c2cc12c9043d3f6c22b3af3babf18920e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284021
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2023-12-11 21:24:59 +00:00
Konstantin Shcheglov 2803bf6275 Macro. Remove declarationsPhaseInterface formal parameter.
We don't need it with the new free introspect and cycle detection.

Change-Id: I847eac6b62699f55165fb7ec987272d104ecc819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-12-11 18:14:11 +00:00
Konstantin Shcheglov 3ab16cf2ce Use FileState to get file properties, include URI to output.
No need to re-discover WorkspacePackage.

Change-Id: I68a343ec1c18d9f13cf8fbc7c7dce967a3acb6f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-11 17:55:24 +00:00
Konstantin Shcheglov 8371eb481f Macro. Introspect top-level functions.
Change-Id: Ida8e7768efb3072870fd32bb48d0905d235ad343
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340740
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-11 17:36:21 +00:00
Konstantin Shcheglov c31dfad2df Macro. Implement StaticType.isExactly()
Partial tests, only interface types, and nullable.
More in future CLs, as resolution into other `StaticType`s implemented.

Change-Id: Ibab214a0a4625ce26c6090f95d056cfd42a25754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340820
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-11 17:04:38 +00:00
Johnni Winther 17f4344336 [cfe,analyzer] Handle extension types in exhaustiveness checking
This adds support for extension types in exhaustiveness checking by
performing extension type erasure on the type before computing the
corresponding static type/space.

Change-Id: Ie75c903aec52a7c34410695787a9bea6008d637d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340442
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-12-11 11:10:07 +00:00
Erik Ernst f9d64593ff Adjust UP to move the intersection type rules up
This CL implements the spec change in https://github.com/dart-lang/language/pull/3435. It changes the implementation of UP in the CFE and in the analyzer such that it matches the updated specification in language PR dart-lang/language#3435.

Change-Id: I2fb56c11e671e6917baffb89f9fb231072d22a0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333922
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2023-12-11 08:31:10 +00:00
Gihwan Oh 9410b314ab [analyzer] fix typo
Closes https://github.com/dart-lang/sdk/pull/54297

GitOrigin-RevId: 9d83b9899030a5a202b38e9fc4d6cb9f69358a81
Change-Id: Ie334df73b321bc7f4fe32f00e4aa996d0c9508de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-10 20:47:39 +00:00
Konstantin Shcheglov 9facf4d60f Macro. Run declarations phase also when introspecting fields and constructors.
Use DeclareInType() instead of specialized new macros.

Change-Id: I66764ca956c42477dfb6b89162a2904666d54504
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340642
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-08 22:58:00 +00:00
Konstantin Shcheglov d2e2ff9b4b Macro. Introspection of type methods during declarations phase runs the target type macros.
Change-Id: Ibaccebe04463481b9f1db2fbb68f5e513fa1c6df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340641
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-08 20:59:02 +00:00
Sam Rawlins 9d949a2498 analyzer: Remove pre-NNBD code from strong_mode_test; default to NNBD in ResolutionTest
`isNullSafetyEnabled` is now flipped to true in ResolutionTest, and only
overridden to false in WithoutNullSafetyMixin.

Change-Id: If10a5ba852eada2f719450118683a6d42c1002e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340640
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-12-08 18:27:21 +00:00
pq d27b887fec update expectations to include sdk constraints
* Adds sdkConstraints to package string dumps
* Addresses TODO, migrating test to use text-based expectations
* Fixes path issue breaking windows test bots

Change-Id: I7381e18fc6756693a8cf13857d2f467934275f13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340540
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-12-08 03:58:29 +00:00
Dillon Nys cb38f836a2 Include alias in InterfaceTypeImpl.withNullability()
Follow up on https://github.com/dart-lang/sdk/issues/54260. This is another place where `withNullability` fails to pass the optional `alias` associated with the type.

R=leafp@google.com

Bug: https://github.com/dart-lang/sdk/issues/54277
Change-Id: I8d97a9dad209a608cfcc9a6b53a8abc95ea63352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340289
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Dillon Nys <dillon.andre.nys@gmail.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2023-12-08 01:06:15 +00:00
Konstantin Shcheglov 8d8e7edaee Tweak AnalysisContextCollectionTest presentation.
Change-Id: Icea421a2606ffe99beaa5e85dfa0a407e3d950e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340305
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-08 00:51:48 +00:00
Paul Berry 004f564f40 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>
2023-12-07 23:40:27 +00:00
Paul Berry 7dda27b543 inference-update-3: use unpromoted type as context for local variable assignments.
This change implements one of the features of experimental feature
`inference-update-3`: with the experimental feature enabled,
assignments to local variables use the declared (or inferred) type of
the local variable as the context for evaluating the RHS of the
assignment, regardless of whether the local variable is promoted. With
the experimental feature disabled, assignments to local variables
continue to use the promoted type of the local variable as the context
for evaluating the RHS of the assignment.

This eliminates one of the scenarios in which the context type of an
assignment is "aspirational" (i.e., not required to be met in order to
prevent a compile time error). Once all aspirational context types
have been removed from the language, we will be able to re-work
coercions to be based on context type, which fixes a number of
usability footguns in the language. See
https://github.com/dart-lang/language/issues/3471 for details.

Bug: https://github.com/dart-lang/language/issues/3471
Change-Id: Ic07ac1810b641a9208c168846cd5fd912088d62b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338802
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-12-07 23:30:06 +00:00
Parker Lougheed 13fdaa09ac [analyzer] Mark new asset and extension type diagnostic docs as published
Closes https://github.com/dart-lang/site-www/issues/5396

Bug: https://github.com/dart-lang/site-www/issues/5396
Change-Id: Ic4ebe03fd7195a241608cffebfd91b11125c7fa2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Marya Belanger <mbelanger@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
2023-12-07 22:04:48 +00:00
Konstantin Shcheglov 9683fd4a50 Macro. Update introspection text after model change.
Oh, accidentally we were just discussing it :-)

Change-Id: If54d17665a9fa5c01834f1410f307301f916be67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-12-07 21:43:34 +00:00
Konstantin Shcheglov 79e0e1527d Macro. Switch on CompilationUnitMemberImpl, sealed, no need for default.
Change-Id: Ic487425149039a85514caead0b4dcc1ace5cd12a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340380
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-12-07 21:40:47 +00:00