Files
sdk/tests
Paul Berry bb524468ef Wire up "why not promoted" messages for failed field promotion due to conflict.
Previously, when field promotion failed due to a conflict with another
declaration in the same library, the client (analyzer or front_end)
was responsible for returning a value of
`PropertyNonPromotabilityReason.isInterferedWith` from
`Operations.whyIsPropertyNotPromotable`. Flow analysis would propagate
this value into a `PropertyNotPromoted` object whose
`documentationLink` getter returned `null`. The client was then
responsible for tracking down all the conflicting fields and getters
and creating the appropriate context messages for them (but this
functionality wasn't implemented yet).

With this change, the `PropertyNotPromoted` is now abstract, with two
subclasses to represent the two cases the client has to handle:

- `PropertyNotPromotedForInherentReason` to cover the case where a
  property cannot be promoted due to the fact that it is inherently
  not promotable (i.e. it's not final, it's public, it's external,
  it's not a field, or it's in a library where field promotion isn't
  enabled). In this case the client simply has to generate the
  appropriate context message and attach it to the site where the
  property is declared, and it can rely on having access to a non-null
  `documentationLink` to include in the context message.

- `PropertyNotPromotedDueToConflict` to cover the case where the
  property cannot be promoted due to a conflict with some other
  property in the same library. In this case the client has to
  generate multiple context messages, one for each conflicting
  declaration, and it has to associate each one with the appropriate
  documentation link from the `NonPromotionDocumentationLink` enum.

The `NonPromotionReasonVisitor` base class has been updated to reflect
this split, so that the logic for handling these two cases is in
separate methods in the client.

The front_end logic for handling non-promotion due to conflict is now
fully implemented. The analyzer logic will be addressed in a follow-up
CL, since it's more complex (it requires plumbing additional data
through the summary file format).

Finally, the nomenclature in the `FieldNameNonPromotabilityInfo` is
adjusted to match the new context messages.

Change-Id: Ieed70d1a3572abbc726ae34584d85c7a8aee0732
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/327712
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-09-28 03:37:01 +00:00
..
2023-09-19 20:59:33 +00:00
2023-09-19 20:59:33 +00:00
2022-12-19 12:56:47 +00:00

This directory contains tests of the language and core library implementations. For more information, see https://github.com/dart-lang/sdk/wiki/Testing.