Replace unscoped with UnscopedRefAttribute#6329
Merged
cston merged 4 commits intodotnet:mainfrom Jul 29, 2022
Merged
Conversation
jcouv
reviewed
Jul 28, 2022
| Impact of this change is discussed more deeply [below](#examples-method-arguments-must-match). Overall this will allow developers to make call sites more flexible by annotating non-escaping ref-like values with `scoped`. | ||
|
|
||
| The `scoped` modifier on parameters also impacts our object overriding, interface implementation and `delegate` conversion rules. The signature for an override, interface implementation or `delegate` conversion can: | ||
| The `scoped` modifier and `[UnscopedRef]` attribute (see [below](#rules-unscoped)) on parameters also impacts our object overriding, interface implementation and `delegate` conversion rules. The signature for an override, interface implementation or `delegate` conversion can: |
Member
There was a problem hiding this comment.
What are the rules for [UnscopedRef] in OHI? Is any variance allowed? #Closed
jcouv
reviewed
Jul 28, 2022
| <a name="rules-unscoped"></a> | ||
|
|
||
| To fix this the language will provide the opposite of the `scoped` lifetime annotation in the syntax `unscoped`. The keyword `unscoped` will be used to expand the lifetime of a value. It can be applied to any `ref` which is implicitly `unscoped` and has the impact of changing its *ref-safe-to-escape* to *calling method*. | ||
| To fix this the language will provide the opposite of the `scoped` lifetime annotation by supporting an `UnscopedRefAttribute`. The attribute can be used to expand the lifetime of a value. It can be applied to any `ref` which is implicitly `scoped` and has the impact of changing its *ref-safe-to-escape* to *calling method*. |
Member
Member
There was a problem hiding this comment.
Also, is it an error to place [UnscopedRef] on some location that doesn't qualify per above?
Contributor
Author
There was a problem hiding this comment.
Consider enumerating those implicitly scoped ref cases if it's easy.
Added a link to the cases described earlier.
Also, is it an error to place
[UnscopedRef]on some location that doesn't qualify per above?
Added as an error.
jcouv
reviewed
Jul 28, 2022
Member
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (iteration 2). Looks good except for a question on OHI. Thanks much!
jcouv
reviewed
Jul 28, 2022
| To fix this the language will provide the opposite of the `scoped` lifetime annotation in the syntax `unscoped`. The keyword `unscoped` will be used to expand the lifetime of a value. It can be applied to any `ref` which is implicitly `unscoped` and has the impact of changing its *ref-safe-to-escape* to *calling method*. | ||
| To fix this the language will provide the opposite of the `scoped` lifetime annotation by supporting an `UnscopedRefAttribute`. | ||
| The attribute can be used to expand the lifetime of a value. It can be applied to any `ref` which is [implicitly `scoped`](#implicitly-scoped) and has the impact of changing its *ref-safe-to-escape* to *calling method*. | ||
| An error is reported if `[UnscopedRef]` is applied to a parameter passed by value or to a `ref` that is not considered scoped. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.