Commit Graph

9138 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
Ömer Ağacan 91374ffb12 [dart2wasm] Minify more errors
Transform front-end generated `throw` expressions (as indicated by the
kernel node's `forErrorHandling` flag) to error throwing functions that,
in minify mode, throw without details.

ACX demo sizes: (`-O2 --minify`)

- Before: 12,841,863 bytes
- After: 12,396,399 bytes
- Diff: -445,464 bytes, -3.46%

Issue: https://github.com/dart-lang/sdk/issues/60432
Change-Id: I3c0bfebd5a9cb460af312dafb63b5a0c9aeda22e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430380
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-05-23 03:31:36 -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
Alexander Markov b083c9ac87 [dyn_modules] Handle implicit uses from const constructors and field initializers of const classes
When const constructor is exposed through a dynamic interface,
dynamic module can create constants with that const constructor and
it can reference everything used in that constructor including default
values of parameters and field initializers. So dynamic interface
annotator should visit bodies of const constructors and add all
references to implicit uses.

Annotator should also visit initializers of instance fields of
classes which can be used in a constant (as they participate in
the constant evaluation too). Kernel trim tool should not remove such
field initializers.

TEST=pkg/dynamic_modules/test/data/const_constructor
Fixes b/418928636

Change-Id: Ie216f3a4257fe5a905b83af8c60dfe8a5b774ecf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430002
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2025-05-22 06:39:25 -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 93146ecc73 [cfe] Pass content maps to NameSpaceImpl
This moves the computation of the content map from getables/setable
outside the NameSpaceImpl. This is in preparation for implementing
getter/setter and final field/setter through the same PropertyBuilder.

Change-Id: I2c91f7ee9f2650f87ac9512d18834c31684c7309
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429942
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-21 07:03:53 -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
Daco Harkes 8ac2279b07 [native assets] Graduate to preview
This PR enables native assets on the main and dev channel by default,
and make native assets available on the beta channel.

This PR removes the flag from invocations.

The helper packages (`package:hooks` and `package:code_assets`) will
stay 0.x for now, until the SDK constraint can be bumped to a beta
release and we're happy with the Dart API.

`dart build` is also made available as preview (without a flag on
the main, dev, and beta channels). We're still finalizing the spec for
this command. (https://github.com/dart-lang/sdk/issues/60730)

`dart test` will need https://github.com/dart-lang/test/pull/2501.
This means users will need to update their `package:test` dependency.

This PR refactors the way that invalid `package_config.json`s are
handled: they are now loaded in the dartdev commands and handled there.

Bug: https://github.com/dart-lang/sdk/issues/50565
Project: https://github.com/orgs/dart-lang/projects/99/

Change-Id: I7db9ff6d7196750cab9379a4605c6bbf89a974d7
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429920
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-05-21 06:10:19 -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 c8aab9f302 [dyn_modules] Do not trim field initializers in mixins
When applying a mixin during dynamic module compilation, fields and
methods are copied from kernel AST of the mixin.
So field initializers within mixins should be preserved while trimming
host app kernel file, in order to be available for the dynamic module
compilation.

TEST=pkg/dynamic_modules/test/data/mixin_field
Fixes b/418729276

Change-Id: I00c4392989d552e24dc8c4b4b60c1667de234f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429680
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-05-20 10:27:36 -07:00
Stephen Adams a2312f4776 [js_interop] Use stub for dart2js only when method has annotations
In order to support dart2js pragma annotations on external js_interop
methods, add the ability to generate stubs for getters, setters and
methods. Create stubs for dart2js only when the method has annotations.
Methods can only be handled by stubs when there are a fixed number of
positional arguments,

Move from using a `builder` to using a slightly more general
'treatement' that can also replace the Procedure's function body.

Issue: #60746
Change-Id: I7482f09d430448001d712dd4645d23f78910920d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429203
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-20 09:34:52 -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 ca694e46c1 [model] Remove nullability-related error messages in map literals
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/428980

Change-Id: I7b6b3e2cc920f29b4ce4f409615efb7a858e9fe4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-19 05:06: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
Chloe Stefantsova bd92c25d53 [model] Remove nullability messaging in subtyping error messages
The subtype checking mode that ignores the nullability and is enabling
the nullability-related messaging is to be removed. This CL cleans up
the test expectations for that change.

Change-Id: I39e1fbf40192d1434b87e38cbe00eb68a965f0df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428782
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-16 00:58:00 -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
Kallen Tu ecc6b93abd [cfe/analyzer] Dot shorthands: Abstract constructors can't be instantiated or torn off.
Adding a few errors on when we instantiate or tear off abstract constructors. Should be parallel to how we currently check for these errors in the CFE and analyzer.

Follow up to https://dart-review.googlesource.com/c/sdk/+/426682

Language test added, co19 test passing, and unit tests added.

Bug: https://github.com/dart-lang/sdk/issues/59758, https://github.com/dart-lang/sdk/issues/59835
Change-Id: I9b34e5f960856ce50aa969ca27e56907ae3a2a8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/428201
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-13 10:10:51 -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 7436b97ba4 [flow analysis] Allow non-cascaded field accesses to participate in field promotion.
The way this is accomplished is that in
`_FlowAnalysisImpl.nullAwareAccess_rightBegin`, any expression
reference associated with the target of the null-aware access is
restored, and the corresponding SSA node is associated with the guard
variable (if any). These changes ensure that if the null-aware access
is a property get, the subsequent call to `propertyGet` will pick up
the appropriate SSA node, so it will be able to locate the promotion
key for the property.

This functionality is only enabled when the language feature
`sound-flow-analysis` is enabled.

To prevent test regressions, a few related changes need to be made at
the same time:

- `_FlowAnalysisImpl.nullAwareAccess_end` is changed so that it clears
  any expression info or expression reference that was associated with
  the null-aware access expression. This prevents flow analysis
  information from being erroneously propagated out of a null-aware
  expression, which would have led to assertion failures when
  analyzing null-aware expressions inside of conditional
  expressions. This wasn't previously a problem because the expression
  reference used to be consumed by
  `_FlowAnalysisImpl.nullAwareAccess_rightBegin`, preventing further
  expression references and expression infos from being recorded
  further along in the null-aware access.

- The test framework in `mini_ast.dart` is fixed so that `!` is
  considered to participate in null shorting. This was a bug in the
  test framework that wasn't previously caught because it happened not
  to produce any test failures.

- The analyzer's method `PostfixExpressionResolver._resolveNullCheck`
  is changed so that it calls `nonNullAssert_end` before terminating
  null-aware access. Previously, the order was swapped, causing
  `nullAwareAccess_end` to be called before `nonNullAssert_end` when
  analyzing expressions like `a?.b!`. This used to be benign, but now
  that non-cascaded field accesses participate in field promotion,
  flow analysis needs the methods to be called in the correct order.

Fixes https://github.com/dart-lang/language/issues/4344.

Bug: https://github.com/dart-lang/language/issues/4344
Change-Id: I523be1b4be1af3f68654a745187a546728c878fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427820
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-12 08:25:20 -07:00
Paul Berry c757fda685 [front end] Eliminate unnecessary code path.
Now that null-aware guard variables are handled specially by flow
analysis (see https://dart-review.googlesource.com/c/sdk/+/427341),
all variables passed to `OperationsCfe.variableType` are instances of
`VariableDeclarationImpl`.

Change-Id: I1c7d990cc7f0539767c476e9a884aeff90af6a23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427800
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-05-12 08:00:40 -07:00
Paul Berry 4cdb2df303 [flow analysis] Re-work handling of CFE null-aware guards.
The CFE desugars null-aware expressions such as `a?.b` into equivalent
`let` expressions involving a temporary guard variable (e.g., `let x =
a in x == null ? null : x.b`). This desugaring happens in the body
builder, prior to flow analysis. As a result, the expressions and
variables passed to flow analysis are those of the desugared `let`
expression rather than those of the code the user wrote. So a hack is
needed to ensure that flow analysis produces the correct result; the
hack involves promoting the temporary guard variable in the code path
where it is not null.

Prior to this change, the hack was done entirely in the CFE. Instead
of making a single pair of calls to
`FlowAnalysis.nullAwareAccess_rightBegin` and
`FlowAnalysis.nullAwareAccess_end` for every null-aware expression,
the CFE made two nested pairs of calls: one to promote the true target
of the null-aware access, and the other to promote the temporary guard
variable.

This had the advantage of keeping the hack entirely in the CFE, but
unfortunately it got in the way of fixing
https://github.com/dart-lang/language/issues/4344, because it
prevented flow analysis from properly recognizing field accesses
inside null-aware expressions.

This change adds an optional `guardVariable` parameter to
`FlowAnalysis_nullAwareAccess_rightBegin`, and shifts the
responsibility for promoting the temporary guard variable to the flow
analysis engine itself. With this change, the CFE no longer needs to
make two nested pairs of calls to
`FlowAnalysis.nullAwareAccess_rightBegin` and
`FlowAnalysis.nullAwareAccess_end`, and flow analysis now has the
necessary information to recognize field accesses inside null-aware
expressions.

I will perform the actual fix for
https://github.com/dart-lang/language/issues/4344 in a follow-up CL.

Note that in the future, I would like to change the CFE so that it
desugars null-aware accesses during type inference rather than during
the body builder; this will allow the expressions and variables passed
to flow analysis to be precisely those of the code the user wrote;
that in turn will give us extra confidence that flow analysis produces
the same results in the analyzer and the CFE.

Change-Id: Ie63619a3ca0f011c1ae8e3c0c76b5bc7c1ab8419
Bug: https://github.com/dart-lang/language/issues/4344
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427341
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-05-12 05:30:10 -07:00
Johnni Winther 94c9dff1c5 [cfe] Add isInternalImplementation to Extension(Type)MemberDescriptor
This adds a flag to the member descriptors that allow us to skip these when building the name space for extensions and extension types from dill.

The late lowering of fields in dart2js is fixed to support lookup from dill.

Change-Id: Iacbd6451ac234767036dfe8f818c3ecbb693ced8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427720
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-12 00:26:25 -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
Paul Berry a757d2af41 Enable sound-flow-analysis for Dart 3.9.
Bug: https://github.com/dart-lang/sdk/issues/60438
Change-Id: I908d4e4a9143142281d8198870f40eba6cf6f67f
Tested: trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427500
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-05-09 14:50:26 -07:00
Johnni Winther 2455ace91b Revert "[model] Update handling of ?.length in constants"
This reverts commit b5e1ef4e14.

Reason for revert: Analyzer didn't report an error in all cases, so this is a breaking change.

Original change's description:
> [model] Update handling of ?.length in constants
>
> This adds reporting of an error in CFE for ?.length in constant expressions and improves the message for the analyzer in the same case. The error in the analyzer was previously the invalid claim that
>
>     The property 'length' can't be accessed on the type 'Null' in a constant expression.
>
> Closes #60509
>
> Change-Id: Ibbe0fa1ace3bea9d83efea2ccf3ea9716a125d74
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421841
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Change-Id: I1bbe77b7abed5603dc062a235463bb4e0e755f23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426860
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-07 05:16:59 -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 e582b10e1c [cfe] Remove SourceMemberBuilder.isAugmentation
This removes the SourceMemberBuilder.isAugmentation property along with other properties related to builder as augmentation. These no longer makes sense and the access to augmented members needs to be rebuilt when the augmentation feature is revived.

Change-Id: Ic978d2f0f60eddacda924c887675eb9f4659a1ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426801
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-05-06 03:50:22 -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 918899974a [cfe] Add PrimaryConstructoFieldFragment
This creates a PrimaryConstructorFieldFragment instead of a FieldFragment for primary constructor fields (currently only occurring in extension types).

Change-Id: Iec58112a0a0ef64dba248f1ce93625e297b10705
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426460
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-05-05 03:45:17 -07:00
Johnni Winther b5e1ef4e14 [model] Update handling of ?.length in constants
This adds reporting of an error in CFE for ?.length in constant expressions and improves the message for the analyzer in the same case. The error in the analyzer was previously the invalid claim that

    The property 'length' can't be accessed on the type 'Null' in a constant expression.

Closes #60509

Change-Id: Ibbe0fa1ace3bea9d83efea2ccf3ea9716a125d74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421841
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-05-05 01:10:33 -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 82960603a1 [model] Check setters of late lower fields in overrides
This CL includes the setters induced by late lower fields into the
override checks. Due to this change the erroneous overrides will be
marked as such.

Change-Id: Ie1ca9e6ab7e55c076c713b55dc85c6284af45ffe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-02 03:42:13 -07:00
Chloe Stefantsova 01d42a9357 [model] Only infer first required positional parameter in setters
This CL makes sure that only the first required positional parameter
is inferred in setters. Optional positional and named parameters,
which are erroneous in the case of setters, aren't inferred. That
prevents reporting of some cascading errors.

Change-Id: If89628adf542a325aa7320557c131abb7987a687
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426040
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-05-02 01:02:50 -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 f749040450 [model] Keep Let expressions intact in the verifier
Prior to this CL the CFE verifier would update the type of the
variable in Let expressions from `dynamic` to the computed static type
of the initializer. This CL removes the type update, making the
.expect files reflect the CFE output more accurately. Additionally, a
verification check is added to make sure the static type of the
initializer is assignable to the type of the Let variable.

Change-Id: I0b7b8f175bcb319678c323eb6440d93f1f384a85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425500
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-30 03:25:50 -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
Sigmund Cherem 0064249ab3 [trim] relax language version requirement.
Only enforce that a library must be 3.0 or higher if it
contains extendable elements. Otherwise, we can ignore legacy
mixin classes and trim the entire library.

TESTED=apply_mixin case in dynamic_modules tests.

Change-Id: I1378c6d4678305ae634b4259e7eb28a48327d645
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425187
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2025-04-29 09:38:55 -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
Chloe Stefantsova 496db5d366 [model] Mark constructors not initializing final fields as erroneous
Change-Id: I2f464ee708396cb916e420f0985cd39ca0bfe2f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-04-29 01:26:44 -07:00
Moritz 7a83c82b4f [record_use] Don't record locations for usages and other refactorings
In preparation of a merge with the Dart2Js format in a follow up PR.

- Treat default values as passed arguments - `foo(4)` is the same as
  `foo()` for all intents and purposes for a `foo([int i = 4])`.
- Add signatures to lookup, as dart2js forgets them during
  compilation.
- Encode non-constant arguments as `null`, while a `null` passed as an
  argument is a `NullConstant`.

Tested:pkg/vm/test/transformations/record_use_test.dart
Change-Id: Ifd2597d8d1b979627fa45fd4736a762031c17216
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415620
Commit-Queue: Moritz Sümmermann <mosum@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Moritz Sümmermann <mosum@google.com>
2025-04-28 06:12:00 -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