Commit Graph

3359 Commits

Author SHA1 Message Date
Jens Johansen 3deffabce1 [CFE] Update flutter_gallery_leak_tester to use flutter/dev/integration_tests/new_gallery
For a few months the "original" flutter gallery has had compile errors
and the weekly bot has been a lot slower (and doesn't really test the
default "advanced invalidation").

This updates the compile target to the one in
flutter/dev/integration_tests/new_gallery which doesn't have compile
time errors.

Change-Id: I59aa701700bc6b3530d73d9c0474dbff525288c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-05-23 04:50:30 -07:00
Chloe Stefantsova 561f2a3cff [model] Update DEPS to use new benchmark data for CFE subtype checks
Change-Id: Id428e294952f810ece7f83e8afad23db1c0f0d5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-23 01:57:10 -07:00
Chloe Stefantsova 00acecdfbe [model] Upate bench maker and parser for recent type system changes
This CL includes changes to BenchMaker and test type parser that
include recent developments in the DartType system, such as extension
types and record types, outstanding existing features, such as
typedefs, and recent changes in the CFE type model, such as structural
parameters.

Change-Id: I16ca13273e83de7942abad67b8a2b67146fb24bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-23 01:57:10 -07:00
Johnni Winther 27354572b4 [cfe] Add _createPropertyBuilder
This combines the creation SourcePropertyBuilder for fields, getters,
setters, enum elements and primary constructor fields through the same
method.

This prepares for combining getter/setter and final field/setter
pairs in the same SourcePropertyBuilder.

Change-Id: I664ccded46c79235281cbd0799f9567bfb451eb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430440
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-23 01:26:42 -07:00
Johnni Winther 2b492a8d24 [cfe] Add UriOffsetLength
This adds a UriOffsetLength that passes uri, offset and length of a source locations. This is used to support
field/getter/setterUriOffset to prepare for getter/setter and final
field/setter pairs to be contained in the same builder object, while
still allowing messaging to point to the specific aspect.

UriOffsetLength is furthermore used on ClassMember which improves the
precision of messages from hierarchy checks.

Change-Id: I0776c8b66177164e326d3fb61e32a7620955f4c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429961
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-22 01:52:32 -07:00
Johnni Winther dceefd02ca [cfe] Cleanup DillLibrary/ExportNameSpace implementation
This simplifies the computation of DillExportNameSpace and removes the
need for LazyNameSpace.

Change-Id: I6f29e9a6def47ed8751437b57c6ad7d29fcf494a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429940
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-21 07:03:53 -07:00
Chloe Stefantsova e535e812be [model] Update instructions for generating benchmark data in CFE
Change-Id: I505390321f8ca26391503dd4645b56a208108fc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-21 01:45:11 -07:00
Alexander Markov 0f42d66b6f [dyn_modules] Fix overriding of a method declared in a mixin
Mixin transformation copies members of a mixin into a mixin
application class. Copied members should still behave similarly to
original members in terms of overriding.

When validating a dynamic module, overriding a copy of mixin
member should be allowed if original member can be overridden.

When annotating AST with dynamic interface pragmas, can-be-overridden
pragmas should apply to all copies of mixin members.

TEST=pkg/dynamic_modules/test/data/override_mixin_method
Fixes b/418681054

Change-Id: I038ff2133ef6f0c288a47cec7300c6ac4b23cbab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429423
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-20 06:25:00 -07:00
Johnni Winther e7ef1b315e [cfe] Implement name spaces using LookupResult
This changes the implementations of NameSpace to use a map of type
Map<String, LookupResult> internally instead of two getables/setables
maps of type Map<String, NamedBuilder>.

This is done in preparation for combining getter/setter and final field/
setter into a single PropertyBuilder object.

Change-Id: I4c1b95db17ff08ba136c20c52a8677a28c6a99a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429363
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-20 01:25:42 -07:00
Chloe Stefantsova 617d0a8e96 [model] Remove more nullability-related assignability error messages
This is a preparation for removing the subtype checking procedure that
ignores the nullability in the input types.

Change-Id: I3c1db55abde0433e9059d949f1c98aaeb61e210c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428980
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-19 00:18:57 -07:00
Johnni Winther d56cabaf1f [cfe] Remove member/constructor iterators from NameSpace
This remove the iterators from the NameSpace interface and instead
collects the list of builders belonging to a library or declaration
directly inside these builders.

Adds ComputedNameSpace for import, export and prefix name spaces. This
allows for replacing a member and has a filteredIterator function. These name spaces are computed from import/exports and therefore need to be iterated through directly and replace builder when two builders collide.

Change-Id: Iec974656c5331498aa1cfca7973300ac6e044994
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-16 05:07:01 -07:00
Johnni Winther 5087b62279 [cfe] Check NameSpace.addLocalMember
This adds assertions to NameSpaceImpl.addLocalMember to ensure that the name space entries are not overwritten unexpectedly.

The computations of library and declaration name spaces from dill are changed to exclude private members from other libraries which might otherwise replace exiting members.

To support private class members inherited from other libraries as
of the member hierarchy computation, the member builders in a dill
class builder are kept separately from the name space.

Change-Id: Ib6b24e539a838093a3a5a2abfc056dfc3883903c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427701
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-15 01:53:13 -07:00
Johnni Winther 3b553b3c4b [cfe] Add Mutable(Declaration)NameSpace
This removes the mutators from the (Declaration)NameSpace interface and
adds concrete subclasses for the various use cases.

Change-Id: I0728acdd93659d2e118aadfe02749cee3a47afb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427703
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-13 05:11:51 -07:00
Johnni Winther 2f27b68130 [cfe] Cleanup NameSpace
This remove part of the NameSpace to avoid an overreliance on its implementation. This is done in preparation for hold the name space content in a single map instead of a separate map for getables and setables.

The NamedBuilder interfaces is added to use for Builders that can be mapped in name spaces. This avoids the need for the NameIterator and all the associated methods.

Change-Id: Ia547bdc8ddcb83f47473b51a2059428b352f8916
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428001
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-13 01:15:33 -07:00
Paul Berry 0fcd1a6fa1 Bump _fe_analyzer_shared to SDK 3.7 and reformat
Change-Id: I70157caf90c0955c2eb8426f5721ba4ed527eb76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427900
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-10 15:32:50 -07:00
Chloe Stefantsova c11186b47d [model] Recognize erroneous program encodings in the CFE verifier
For some erroneous programs the CFE produces the code that's not
type-safe or valid from the standpoint of a correct program. That
should not trigger the verifier warnings though.

Change-Id: I78b51ccffb0a74658926728e1a7ee3bf56934fe6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426500
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-07 01:03:13 -07:00
Sam Rawlins 49562fd152 analyzer: Deprecate ErrorCode in favor of replacement: DiagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I0cfc0bff4e5d10b7cb373f77de55fffc13b8cf76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426641
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-06 14:43:10 -07:00
Johnni Winther 5874ba32e9 [cfe] Unify getter/setter/field references
This unifies the handling of getter/setter/field references into one object. The references for internal parts of the late lowering are removed. These are not need because the member are never accessed from outside the library and all uses are therefore created together with the reference objects.

Change-Id: I9a18d9f18fa379ee73a74ebadebd473dcb1649aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426800
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-05-06 01:47:40 -07:00
Johnni Winther a077989c9d [cfe] Return LookupResult from NameSpace.lookupLocalMember
This prepares for having getters and setters in the same builder.

Change-Id: If800e7cccf1e71dbb7bca628a91a6ab48d8737c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426162
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-05 00:46:15 -07:00
Chloe Stefantsova 40d52d54af [model] Enable checks in redirecting factories of extension types
This CL enables the same checks in the redirecting factories of
extension types as in redirecting factories of classes. Additionally,
this CL marks all of those erroneous constructors, in classes and in
extension type declarations, as erroneous.

Change-Id: Ic270324f05b6a8424c1ab9fbe9fe4f1d0b22a3fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425860
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-01 06:05:34 -07:00
Johnni Winther 7850078ce7 [cfe] Implement getter/setter aspect of fields through Getter/SetterDeclaration
This removes the parts of the FieldDeclaration interface dealing with the getter/setter aspects and instead uses the Getter/SetterDeclaration interfaces.

Change-Id: Ia807c085536c3132527d82491b17b796dfd745bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425521
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-30 06:05:17 -07:00
Johnni Winther f867dc7600 [cfe] Don't create ClassMember for internal implementation
Internal implementation members, like those used for the late lowering, are not real instance members on should not be part of the hierarchy member computation. These members are only called directly from within the members for which these are generated, so we don't need to add forwarders and stubs to handle calls from the outside.

Closes #49339

Change-Id: I4d87477243d4e015265c7bb200e1fb5431ae21f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424943
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-30 03:42:10 -07:00
Chloe Stefantsova aea68e45ac [model] Add ConstructorDeclarationBuilder.markAsErroneous
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/424980

Change-Id: Ia64aa18592a80ac71c04a5e103f13ecf04e50c92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425281
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-29 22:55:06 -07:00
Johnni Winther b0d2e1d0f7 [_fe_analyzer_shared] Add debugPrint
This adds a `debugPrint` method along with methods to support automatic indentation.

The debug helpers are reexported inside package:analyzer and package:front_end for easy access.

Change-Id: I80a4103e6fb30a6b459551184916c3fa26591a20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425280
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-04-29 05:06:03 -07:00
Johnni Winther 3c2f59da47 [cfe] Improve predicate helper for extension (type) members
This adds support for computing the qualified name for all extension and extension type members.

The `lowering_predicates_test.dart` is removed and testing is performed through `predicate_test.dart`.

Change-Id: I334bb85d48b6b1fd8fa01de6576f61168b3e96fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424443
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-29 03:22:54 -07:00
Johnni Winther 809573c914 [cfe] Move FieldDeclaration et al. to their own libraries
Change-Id: I7d086497e4057bd73988772ccdc09e731375a01e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424942
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-28 04:31:32 -07:00
Johnni Winther 7b10dc60ad [cfe] Use fileUri to determine when to create a FileUriExpression
This adds a fileUri property to MetadataBuilder and passes the fileUri of the annotated node

Change-Id: I8772ce012dc0c6f33be1f2a67e78ab6c34222405
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424941
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-04-28 04:31:32 -07:00
Chloe Stefantsova a2b2751d7d [model] Define common helper isKnownType and use in inference
This CL is another step towards the unification between
TypeSchemaEnvironment.solveTypeConstraint in the CFE and
GenericInferrer._chooseTypeFromConstraint in the Analyzer.

Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: I2cfafef6a87b9bde8d1c94f6618e7f633debec0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424040
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-28 02:19:45 -07:00
Johnni Winther b23efe44e8 [cfe] Create *FragmentDeclaration
This adds *FragmentDeclaration interfaces for member declaration in order to separate the interface used by the enclosing builder (which is shared between both syntactical and synthetic declarations) and by the body builder context (which is only needed for syntactical declarations). This also prepares for implementing the getter/setter aspect of a field fragment through the GetterDeclaration/SetterDeclaration interfaces.

Change-Id: I314dfe084b2c9d48782d2f6a0c1ae20ff5f7d8c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424821
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-28 01:04:33 -07:00
Alexander Markov 1c429e9f36 [dynamic modules] Add dart:core to dynamic interface by default
In order to simplify creating dynamic interface yaml files,
the following is added to dynamic interface by default:

callable: dart:core, pragma._
extendable: Object

TEST=pkg/dynamic_modules/test

CoreLibraryReviewExempt: no API changes, only adding pragmas
Change-Id: I925532c4c024ebbcf4972b00be0e0a080d5878fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422024
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-04-25 08:09:59 -07:00
Alexander Markov f75a80392e [dynamic modules] Fix dynamic interface validation of extension types
Instead of validating the erasure of an extension type,
validate that extension type declaration and type arguments
are specified as callable.

TEST=pkg/dynamic_modules/test/data/extension_type2

Fixes b/411433443

Change-Id: I063f0a622abd0d75594c4095573b29a7888f5afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423882
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-04-24 07:58:33 -07:00
Johnni Winther a30330466e [cfe] Remove MemberBuilder.isAbstract
This removes isAbstract from MemberBuilder in order to prepare for using one builder for a getter/setter pair.

Change-Id: Ie25efcb51ca6479c2df71c13518ada33177c8434
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424421
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-24 06:08:21 -07:00
Johnni Winther 55dc02c2b1 [cfe] Remove Builder.isAugment
Change-Id: Idb8d5bb93d4cf8ae46d1d8d975a6c4987cd9b331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424041
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-24 00:29:01 -07:00
Johnni Winther 5e6f501da5 [cfe] Clean up Builder properties
This cleans up and removes a lot of Builder properties in order to prepare for fields, getters and setters sharing the same PropertyBuilder object.

The PropertyBuilder interface is extended with field, getter and setter quality aspect to encode the various ways these can be declared.

Change-Id: I778ac9f2f8c288010beb00bea2525b89685a9df4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424060
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-04-24 00:29:01 -07:00
Alexander Markov 6156dd6e59 [dynamic modules] Respect dyn-module:language-impl:* pragmas during dynamic module validation
Dynamic module validation now accepts reference to classes and members
from 'dart:*' libraries if they are annotated with
dyn-module:language-impl:* pragmas. This matches the behavior of
dynamic interface annotator.

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/418663.

Also, when checking for possible dynamic overrides in TFA,
treat _enumToString from dart:core as a public name because
front-end desugars enums into classes which override
private _enumToString method in a different library.

TEST=pkg/dynamic_modules/test/data/enum
Fixes b/395992622

Change-Id: I45ed9855f806224a510fa4e56962607de3371eb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423820
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-04-23 07:43:02 -07:00
Chloe Stefantsova 475a6fa5bd [model] Remove 'topType' parameter from solveTypeConstraint
The parameter is a remnant of the support for non-Null Safe code. The
removal of the parameter is a step towards the unification between
TypeSchemaEnvironment.solveTypeConstraint in the CFE and
GenericInferrer._chooseTypeFromConstraint in the Analyzer.

Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: Ie7efe25591eaff5cdd34c4fffdcd772f94040c28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422721
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-22 02:43:29 -07:00
Paul Berry de58cf72e0 [sound flow analysis] Implement behaviors for null check patterns.
This change updates the flow analysis logic for null check patterns,
so that when the language feature `sound-flow-analysis` is enabled,
the matched value type is checked for nullability. If it's
non-nullable, then the null check pattern is known to succeed.

There is no behavioral change if the feature `sound-flow-analysis` is
disabled.

Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: Ie68d98d95e30053f992a3f8db6ccdd3978960eb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421583
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-04-10 09:27:42 -07:00
Jens Johansen ce4612dddb [CFE] Add mean absolute numbers to TTestResult; print mean from -> to in benchmarker
Change-Id: If935f5d9668cc1bd12ba3e2af7ae55f3bdea141f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421182
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-04-09 06:02:02 -07:00
Johnni Winther e7e07f73aa [cfe] Normalize repo dir
Uri.base, Platform.script and dart:io operations use the drive letter capitalization of the current working directory, but git, alas, does not. This normalizes the computeRepoDir to match that of Uri.base, thus avoiding spurious errors on Windows.

Change-Id: If4324874fa9b5c73c679c1b67a9481371ce8808d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421161
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-04-08 05:48:41 -07:00
Johnni Winther 0dde212150 [cfe] Add LookupResult
This replaces the individual lookups of getables and setables in LookupScope and NameSpace with single lookup that returns a LookupResult holding both the getable and the setable. This prepares for having getter/setter pairs in the same SourcePropertyBuilder and avoids the need for AccessErrorBuilder for handling lookups of getters where only setters exist and vice versa.

Change-Id: I2b1e2477ed43506d9f94c48acd4b44277b490540
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420080
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-08 03:49:31 -07:00
Paul Berry 6c5c9d384f [sound flow analysis] Implement behaviors for is and as.
This change updates the flow analysis logic for `is` and `as`
expressions so that when the language feature `sound-flow-analysis` is
enabled, the static type of the operand is compared to the type to the
right of the `is` or `as` keyword. If one of the types is non-nullable
and the other type is `Null`, then the type test is known to fail. For
an `as` expression, this means that the code path following the
expression will be marked as unreachable. For an `is` expression, this
means that any code paths that assume it evaluates to `true` will be
marked as unreachable.

Note that these new behaviors break assumptions made by three
pre-existing flow analysis tests. I was able to adjust one of the
tests ("equalityOp_end does not set reachability for `this`") to
preserve its old behavior. The other two tests became redundant, so I
removed them.

There is no behavioral change if the feature `sound-flow-analysis` is
disabled.

Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: Ib3a9e96bd39cf7df4c6c297568763c0f25bc9e39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420164
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-04-04 12:11:58 -07:00
Chloe Stefantsova 001e0e6397 [model] Make null-guarded lowerings of cascades type safe
Change-Id: I035380abdb951a48110029ae93f965ad8bf83093
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/420100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-03 08:47:13 -07:00
Johnni Winther dced5e0482 [cfe] Add LocalTypeParameterScope
This cleans up the LocalScope interface and the handling of named function expressions.

Change-Id: Id0432910a9e65d8ae966dfab67c66248639d241a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419842
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-03 03:43:30 -07:00
Sigmund Cherem 44f8e21c82 [kernel] Adds helper to trim dill files for modular dependencies.
Introduce a helper library to trim components based on what we believe
it is needed for modular bytecode compilation. The script is configured
to accept a set of entry points, so unreachable libraries can be removed
entirely. The contents of the retained libraries is trimmed to remove
method bodies, constructor bodies, and initializers, except for where
they may be needed.


In the near future, this should be expanded to:
* include proper unit testing in the CFE
* review whether additional trimming operations can be made
* consider an explicit representation of trimmed content, to help the
  CFE recover when assumptions are not met (e.g. sentinel markers
  to establish whether a value has been trimmed)
* CFE produces trimmed data directly if needed, without having to first
  produce the full dill.

Tests that specifically stress that we don't over-trim include:
apply_mixin (requires preserving method bodies), const_body (requires
preserving initializers).

TEST=existing and new e2e dynamic module aot tests.

b/394936876

Change-Id: I26db8385bdfe1664b2aea234ec8bb896c7c21230
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418702
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-04-01 08:49:11 -07:00
Johnni Winther 6526b26ddb [cfe] Convert extension_test into expectation tests
With the Builder model refactoring this test made less and less sense on its own. Removing the test enables the removal for properties that don't fit well with the new Builder model. The existing tests have been converted to expectation tests to preserve test coverage.

Change-Id: I0234a110321187870ad969236f58aae634f614cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418022
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-03-27 02:41:25 -07:00
Johnni Winther 2978f9c0d6 [cfe] Remove SyntheticMethodBuilder
This implements the _enumToString synthetic method using MethodDeclaration and SourceMethodBuilder instead of SyntheticMethodBuilder.

Change-Id: I71bcb38b86f84d9ee7b187022c528da756691bed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417821
Reviewed-by: Jens Johansen <jensj@google.com>
2025-03-27 02:41:25 -07:00
Johnni Winther 60ea089c87 [cfe] Handle patch type parameters through fragments
Change-Id: I53bcab1b460737d756e9291ff7b3029c281ebb3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417742
Reviewed-by: Jens Johansen <jensj@google.com>
2025-03-26 01:41:15 -07:00
Johnni Winther d858849304 [cfe] Split TypeParameterBuilder into Source/Dill variants
This is done in preparation for handling patching of type parameters through fragments instead of builders.

Change-Id: Idfefdcae199ccc051d2b821ea4e63e0db7a1d72e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417461
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-03-24 04:00:03 -07:00
Jens Johansen 6ad56c68dc [kernel] Remove NNBD compilation mode dummy from kernel binary
Also clean up some of the magic constants around this.

TEST=CI

Change-Id: Ie02df874cb30761d5ea08ae52c1507cf25318280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416940
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-03-21 06:15:41 -07:00
Johnni Winther 51d0babbf7 [cfe] Cleanup declaration and encoding for SourceFactoryBuilder
Change-Id: I3af44198c4e61da39d08e3954b61b7fb3ad9c135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416962
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-03-20 07:06:01 -07:00