-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Changes around reaches and uses #23584
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
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
27a7ce7
Improve naming and comments around "disallow roots"
odersky c409c5d
First stab at useless checking
odersky 39684dc
Prevent leaking FreshCaps created for parameters
odersky e30a3c8
Drop some TODOs in tests, explain others
odersky b293dca
Fix error message for leaks
odersky dcdae04
Fix rebase breakage
odersky affc77b
Tweak error message
odersky 4d6874e
Some more polishings
odersky 5bb26d8
Update tests to 3.8
odersky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,9 +99,17 @@ extension (tp: Type) | |
case AnnotatedType(tp1, ann) if tp1.derivesFrom(defn.Caps_CapSet) && ann.symbol.isRetains => | ||
ann.tree.retainedSet.retainedElementsRaw | ||
case tp => | ||
// Nothing is a special type to represent the empty set | ||
if tp.isNothingType then Nil | ||
else tp :: Nil // should be checked by wellformedness | ||
tp.dealiasKeepAnnots match | ||
case tp: TypeRef if tp.symbol == defn.Caps_CapSet => | ||
// This can happen in cases where we try to type an eta expansion `$x => f($x)` | ||
// from a polymorphic target type using capture sets. In that case the parameter type | ||
// of $x is not treated as inferred is approximated to CapSet. An example is | ||
// capset-problem.scala. We handle these cases by appromxating to the empty set. | ||
Nil | ||
case _ => | ||
// Nothing is a special type to represent the empty set | ||
if tp.isNothingType then Nil | ||
else tp :: Nil // should be checked by wellformedness | ||
|
||
/** A list of capabilities of a retained set. */ | ||
def retainedElements(using Context): List[Capability] = | ||
|
@@ -575,18 +583,30 @@ extension (sym: Symbol) | |
def hasTrackedParts(using Context): Boolean = | ||
!CaptureSet.ofTypeDeeply(sym.info).isAlwaysEmpty | ||
|
||
/** `sym` itself or its info is annotated @use or it is a type parameter with a matching | ||
* @use-annotated term parameter that contains `sym` in its deep capture set. | ||
/** Until 3.7: | ||
* `sym` itself or its info is annotated @use or it is a type parameter with a matching | ||
* @use-annotated term parameter that contains `sym` in its deep capture set. | ||
* From 3.8: | ||
* `sym` is a capset parameter without a `@reserve` annotation that | ||
* - belongs to a class in a class, or | ||
* - belongs to a method where it appears in a the deep capture set of a following term parameter of the same method. | ||
*/ | ||
def isUseParam(using Context): Boolean = | ||
sym.hasAnnotation(defn.UseAnnot) | ||
|| sym.info.hasAnnotation(defn.UseAnnot) | ||
|| sym.is(TypeParam) | ||
&& sym.owner.rawParamss.nestedExists: param => | ||
param.is(TermParam) && param.hasAnnotation(defn.UseAnnot) | ||
&& param.info.deepCaptureSet.elems.exists: | ||
case c: TypeRef => c.symbol == sym | ||
case _ => false | ||
&& !sym.info.hasAnnotation(defn.ReserveAnnot) | ||
&& (sym.owner.isClass | ||
|| sym.owner.rawParamss.nestedExists: param => | ||
param.is(TermParam) | ||
&& (!ccConfig.allowUse || param.hasAnnotation(defn.UseAnnot)) | ||
&& param.info.deepCaptureSet.elems.exists: | ||
case c: TypeRef => c.symbol == sym | ||
case _ => false | ||
|| { | ||
//println(i"not is use param $sym") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like some debugging leftover. Shall we clean it up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's OK for now. |
||
false | ||
}) | ||
|
||
/** `sym` or its info is annotated with `@consume`. */ | ||
def isConsumeParam(using Context): Boolean = | ||
|
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.