Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Oct 25, 2025

Don't automatically add cap when creating instances of capability classes.

To make up for this, refine the scheme to determine an implied fresh cap from
the class fields.

Also: Fix spurious warnings about redundant capabilities.

…sses

To make up for this, refine the scheme to determine an implied fresh cap from
the class fields.
@odersky odersky changed the title Fix spurious redundant capability warnings Don't add cap when creating instances of capability classes. Oct 26, 2025
@bracevac bracevac self-requested a review October 26, 2025 19:10
Copy link
Contributor

@bracevac bracevac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

then
if ref.captureSetOfInfo.elems.isEmpty then
val deepStr = if ref.isReach then " deep" else ""
report.error(em"$ref cannot be tracked since its$deepStr capture set is empty", pos)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
report.error(em"$ref cannot be tracked since its$deepStr capture set is empty", pos)
report.error(em"$ref cannot be tracked since its $deepStr capture set is empty", pos)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no that would add an extra space in front of deep.

@odersky odersky merged commit 11ecbfb into scala:main Oct 27, 2025
51 checks passed
@odersky odersky deleted the fix-redundancy-warning branch October 27, 2025 20:21
@WojciechMazur WojciechMazur added this to the 3.8.0 milestone Oct 28, 2025
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.

3 participants