56dcbe8c8e
A field is promotable if it is private and final, and there is no non-final field or concrete getter with the same name in the same library. This is the rule the language team has chosen to adopt for which fields are promotable, because it's sufficient to ensure that the promotion is sound, and straightforward to specify. A more complex rule could principle identify more fields that are soundly promotable. The rule has a hidden complexity, though: in circumstances where a concrete class overrides noSuchMethod and implements an interface, if the interface contains a private getter (or field) and the concrete class doesn't provide an implementation for it, the compiler will create a synthetic noSuchMethod forwarder; for soundness, this needs to block promotion as well. So the analyzer needs to partially replicate the logic the compiler uses to determine whether a noSuchMethod forwarder is needed. This is handled by a new file, field_promotability.dart, which walks the class hierarchy to determine which private fields and getters are in the interface of any given class but not in its implementation. Field promotion is not yet enabled by default; to use it you need to enable the experiment "inference-update-2". Bug: https://github.com/dart-lang/language/issues/2020 Change-Id: I5f4ebb6b19626961b9b4c904d69670212668552b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262865 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This directory contains tests of the language and core library implementations. For more information, see https://github.com/dart-lang/sdk/wiki/Testing.