Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Jan 27, 2026

Several fixes and improvements around global capabilities

  1. Allow access to exclusive capabilities also in vals of Stateful classes.
  2. Check external uses only after main cc traversal. We need to know whether any external references are real capabilities with nonempty capture sets.
  3. Recursively drop capabilities with empty captureSetOfInfos in dropEmpties
  4. Make moduleClass work for capture checking
  5. Unroll actions of multiple tryIncludes together. Previously, if a first include succeeded and a following tryInclude failed,
    the elements added by the first tryInclude would have been left in the set
    even though the whole operation failed.
  6. Mark uses of static references that are Idents. We previously forgot the case where a static reference is a simple ident id. This needs to be treated like this.id, where this referes to the enclosing object.

We get a new error for minicheck.scala doe to the last change which goes away when things are put into
an explicit object. This needs follow-up.

Stateful will probably be not well known, so it's helpful to also mention
the possibility to extend Mutable.
We need to know whether any external references are real capabilities with nonempty capture sets.
When deciding which IncludeFailure to print, prefer capabilities that
are not static owners. Static owners are often capabilities only indirectly
and they can be synthetic package objects, which makes error messages
less understandable.
Just in case; does not seem to make a difference for the checkfiles yet.
Previously, if a first include succeeded and a following tryInclude failed,
the elements added by the first tryInclude would have been left in the set
even though the whole operation failed.
@bracevac
Copy link
Contributor

@odersky The example in #23850 is still accepted.

We previously forgot the case where a static reference is a simple ident `id`.
This needs to be treated like `this.id`, where `this` referes to the enclosing
object.

We get a new error for minicheck.scala which goes away when things are put into
an explicit object. This needs follow-up.
The capture set of infos can be recursive, for instance if global objects have mutual
dependencies.
If a uses or uses_init clause is absent, assume it's the empty set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants