-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix capture checking of dependent functions #16264
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 all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
bae5b97
type DependentTypeTree as an inferred type
Linyxus 8c90908
add testcase for #15921
Linyxus 18222b7
tweak tests, add limitation errors
Linyxus 7e695fd
one more test case for capture checking dependent functions
Linyxus dd88672
refine propagation for idempotent maps
Linyxus f45e083
make expected function type dependent when the actual type is dependent
Linyxus 62975d3
heal ill-formed capture sets in type parameters
Linyxus 406f51b
tweak tests
Linyxus 0e7d33a
polish implementation
Linyxus 1afbf74
test case for type parameter capture set healing
Linyxus abd085e
use a type traverser to heal capture sets
Linyxus 80830e3
tweak test cases
Linyxus fcf85ad
rename function and add doc
Linyxus dfd077e
address review comments
Linyxus f889563
check the result of widened capture set inclusion
Linyxus c4240fb
use captureSetOfInfo
Linyxus 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
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
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
trait Cap { def use(): Unit } | ||
|
||
def main() = { | ||
val f: (io: {*} Cap) -> {} () -> Unit = | ||
io => () => io.use() // error | ||
|
||
val g: ({*} Cap) -> {} () -> Unit = | ||
io => () => io.use() // error | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import language.experimental.captureChecking | ||
|
||
trait Cap { def use(): Unit } | ||
|
||
def localCap[T](op: (cap: {*} Cap) => T): T = ??? | ||
|
||
def main(io: {*} Cap, net: {*} Cap): Unit = { | ||
val test1 = localCap { cap => // error | ||
() => { cap.use() } | ||
} | ||
|
||
val test2: (cap: {*} Cap) -> {cap} () -> Unit = | ||
localCap { cap => // should work | ||
(cap1: {*} Cap) => () => { cap1.use() } | ||
} | ||
|
||
val test3: (cap: {io} Cap) -> {io} () -> Unit = | ||
localCap { cap => // should work | ||
(cap1: {io} Cap) => () => { cap1.use() } | ||
} | ||
|
||
val test4: (cap: {io} Cap) -> {net} () -> Unit = | ||
localCap { cap => // error | ||
(cap1: {io} Cap) => () => { cap1.use() } | ||
} | ||
|
||
def localCap2[T](op: (cap: {io} Cap) => T): T = ??? | ||
|
||
val test5: {io} () -> Unit = | ||
localCap2 { cap => // ok | ||
() => { cap.use() } | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
trait Stream { def close(): Unit = (); def write(x: Any): Unit = () } | ||
|
||
object Test { | ||
def usingLogFile[T](op: (c: {*} Stream) => T): T = | ||
val logFile = new Stream { } | ||
val result = op(logFile) | ||
logFile.close() | ||
result | ||
|
||
val later = usingLogFile { f => () => f.write(0) } // error | ||
later() // writing to closed file! | ||
} |
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
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
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.
Consider adding a doc comment what it does