- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.1k
 
Implement inheritance condition for Mutable types #24253
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
Implement inheritance condition for Mutable types #24253
Conversation
| - `{x, ...}.RD = {x.rd, ...}.RD` | ||
| - `{x.rd, ...} <: {x, ...}` | ||
| 
               | 
          ||
| ## Separation Checking | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we dropping all these descriptions on separation checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are in a separate file: separation-checking.md
| **Restriction:** A non-mutable type cannot be downcast by a pattern match to a mutable type. (Note: This is currently not enforced) | ||
| 
               | 
          ||
| **Definition:** A class is _read_only_ if the following conditions are met: | ||
| **Definition:** A parent class constructor is _read-only_ if the following conditions are met: | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to make sense of this restriction: does it mean that if you decide to mark a class as mutation-tracked, then all exclusive capability from this class must also be tracked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. Because when we widen the type to something that does not extend Mutable, we make the capture set read-only.
| When we create an instance of a mutable type we always add `cap` to its capture set. For instance, if class `Ref` is declared as shown previously then `new Ref(1)` has type `Ref[Int]^`. | ||
| 
               | 
          ||
| **Restriction:** A non-mutable type cannot be downcast by a pattern match to a mutable type. | ||
| **Restriction:** A non-mutable type cannot be downcast by a pattern match to a mutable type. (Note: This is currently not enforced) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought a bit about this and was wondering whether we can do this by inspecting capture sets in the pattern: one may never "widen" a readonly set to a exclusive one since that will be a permission upgrade.
So instead of preventing narrowing we prevent widening, very much like what we are already doing for capture sets.
f4b401e    to
    97a2ef2      
    Compare
  
    
No description provided.