dart-lang / dart-lang/language

Class modifiers in multi-library packages

Open
#3,113 9 comments 3 reactions 0 assignees View on GitHub
request
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

Class modifiers are a very intriguing feature of Dart 3, but at present they're difficult to use in a project that otherwise follows general Dart best practices of separating concerns into different libraries that only expose the necessary APIs at library boundaries. If you want to get the benefits of exhaustiveness checking for a given class hierarchy, for example, you either have to include the entire hierarchy in one massive library, or use `part of` which obfuscates loads and references. Both of these solutions prevent effective cross-library encapsulation.

This is, admittedly, a difficult problem given that the Dart language doesn't have any notion of multi-file groups like "packages". That said, I'm hoping there's a middle ground that could be reached to allow these modifiers to be useful without pulling everything into the same file. As a straw example, you could treat libraries that are `import`ed by a class's library as "in the same library" for class modifier purposes. This would ensure that you can still determine the full scope of a `sealed` class by resolving its library.

Contributor guide

Open the contributing guide

Research direction

Start by reading the Dart 3 class modifiers and library-boundary rules, focusing on sealed hierarchies, imports, and part-of libraries. Compare the current exhaustiveness and visibility behavior with the proposed multi-library model; done means a concrete, specified approach that preserves encapsulation and defines how the full sealed hierarchy is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.