forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle local type parameters in markFree
These need to be handled like reach capabilities. Fixes scala#21347
- Loading branch information
Showing
3 changed files
with
43 additions
and
14 deletions.
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
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() |