-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fix setup of CapSet arguments. #21309
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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 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 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 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,11 @@ | ||
-- Error: tests/neg-custom-args/captures/i21313.scala:6:27 ------------------------------------------------------------- | ||
6 |def foo(x: Async) = x.await(???) // error | ||
| ^ | ||
| (x : Async) is not a tracked capability | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/i21313.scala:15:12 --------------------------------------- | ||
15 | ac1.await(src2) // error | ||
| ^^^^ | ||
| Found: (src2 : Source[Int, caps.CapSet^{ac2}]^?) | ||
| Required: Source[Int, caps.CapSet^{ac1}]^ | ||
| | ||
| longer explanation available when compiling with `-explain` |
This file contains 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,15 @@ | ||
import caps.CapSet | ||
|
||
trait Async: | ||
def await[T, Cap^](using caps.Contains[Cap, this.type])(src: Source[T, Cap]^): T | ||
|
||
def foo(x: Async) = x.await(???) // error | ||
|
||
trait Source[+T, Cap^]: | ||
final def await(using ac: Async^{Cap^}) = ac.await[T, Cap](this) // Contains[Cap, ac] is assured because {ac} <: Cap. | ||
|
||
def test(using ac1: Async^, ac2: Async^, x: String) = | ||
val src1 = new Source[Int, CapSet^{ac1}] {} | ||
ac1.await(src1) // ok | ||
val src2 = new Source[Int, CapSet^{ac2}] {} | ||
ac1.await(src2) // error |
This file contains 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,15 @@ | ||
-- Error: tests/neg-custom-args/captures/i21347.scala:4:15 ------------------------------------------------------------- | ||
4 | ops.foreach: op => // error | ||
| ^ | ||
| Local reach capability C leaks into capture scope of method runOps | ||
5 | op() | ||
-- Error: tests/neg-custom-args/captures/i21347.scala:8:14 ------------------------------------------------------------- | ||
8 | () => runOps(f :: Nil) // error | ||
| ^^^^^^^^^^^^^^^^ | ||
| reference (caps.cap : caps.Capability) is not included in the allowed capture set {} | ||
| of an enclosing function literal with expected type () -> Unit | ||
-- Error: tests/neg-custom-args/captures/i21347.scala:11:15 ------------------------------------------------------------ | ||
11 | ops.foreach: op => // error | ||
| ^ | ||
| Local reach capability ops* leaks into capture scope of method runOpsAlt | ||
12 | op() |
This file contains 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 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps[C^](ops: List[() ->{C^} Unit]): Unit = | ||
ops.foreach: op => // error | ||
op() | ||
|
||
def boom(f: () => Unit): () -> Unit = | ||
() => runOps(f :: Nil) // error | ||
|
||
def runOpsAlt(ops: List[() => Unit]): Unit = | ||
ops.foreach: op => // error | ||
op() |
This file contains 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,11 @@ | ||
import caps.CapSet | ||
|
||
trait Async: | ||
def await[T, Cap^](using caps.Contains[Cap, this.type])(src: Source[T, Cap]^): T | ||
|
||
trait Source[+T, Cap^]: | ||
final def await(using ac: Async^{Cap^}) = ac.await[T, Cap](this) // Contains[Cap, ac] is assured because {ac} <: Cap. | ||
|
||
def test(using ac1: Async^, ac2: Async^, x: String) = | ||
val src1 = new Source[Int, CapSet^{ac1}] {} | ||
ac1.await(src1) |
This file contains 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,14 @@ | ||
import language.experimental.captureChecking | ||
|
||
class Source[+T, Cap^] | ||
|
||
def completed[T, Cap^](result: T): Source[T, Cap] = | ||
//val fut = new Source[T, Cap]() | ||
val fut2 = new Source[T, Cap]() | ||
fut2: Source[T, Cap] | ||
|
||
|
||
|
||
|
||
|
||
|
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.
This wouldn't work if
Async
was declaredextends caps.Capability