Skip to content

Non-overridable members #27502

Closed
Closed
@munificent

Description

@munificent

Dart specifies that all members, including fields, can be overridden by subclasses or implemented by interfaces.

dev_compiler does not support overriding fields because it forces fields to be compiled to larger, slower JS. Strong mode in turn therefore makes overriding a field a static error.

When investigating instances of that error, Leaf discovered almost every single case where a field was being overridden was in fact bad code. In most cases, the intent for the "field" was actually to declare an abstract getter/setter.

Flutter (among others) have requested to be able to declare that some members cannot be overridden.

The language has committed to at least declaring fields that can and cannot be overridden or implemented. We have not yet decided:

  • If other members can be configured in the same way.
  • What the default should be for fields.
  • What the default should be for other members.
  • What the syntax should be.
  • What the semantics are, especially around implicit interfaces.

This bug is to decide and implement those.

See also: #24928, #27385, #27452, #27372.

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-obsoleteClosed as the reported issue is no longer relevanttype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions