Skip to content

Fix #23223: Add handling for classes deriving from Capability during Setup #23248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 26, 2025

Conversation

noti0na1
Copy link
Member

@noti0na1 noti0na1 commented May 23, 2025

Fix #23223

Updated the Setup logic to handle classes deriving from Capability by adding a fresh capability.

@noti0na1
Copy link
Member Author

Error:

import language.experimental.captureChecking

class Cap extends caps.Capability:
  def use[T](body: Cap ?=> T) = body(using this)
-- [E007] Type Mismatch Error: tests/pos-custom-args/captures/i20237.scala:4:43 
4 |  def use[T](body: Cap ?=> T) = body(using this)
  |                                           ^^^^
  |Found:    (Cap.this : Cap^{cap.rd})
  |Required: Cap^{cap².rd}
  |
  |where:    cap  is the universal root capability
  |          cap² is a fresh root capability created in method use when checking argument to parameter x$0 of method apply

@noti0na1
Copy link
Member Author

cc @Linyxus

@noti0na1 noti0na1 marked this pull request as ready for review May 23, 2025 14:24
@noti0na1 noti0na1 requested a review from Copilot May 23, 2025 14:24
Copilot

This comment was marked as resolved.

@noti0na1 noti0na1 changed the title Add handling for classes deriving from Capability during Setup Fix #23223: Add handling for classes deriving from Capability during Setup May 23, 2025
@noti0na1 noti0na1 requested a review from odersky May 23, 2025 19:32
@noti0na1 noti0na1 requested a review from Linyxus May 23, 2025 19:32
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

I have tweaked the previous scheme so that we only add one capture set variable to a self type. Doing a ++ is correct, but creates two variables, one for the original set and one for the result of the ++.

@noti0na1
Copy link
Member Author

but creates two variables, one for the original set and one for the result of the ++

Oh, I didn't realize there is another variable

@noti0na1 noti0na1 merged commit f906270 into scala:main May 26, 2025
30 checks passed
@noti0na1 noti0na1 deleted the fix-capability-inheritance branch May 26, 2025 19:15
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.

Missing inheritance check for Capability classes
2 participants