-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implied captures in function types
This is an attempt to fix the problem explified in the `delayedRunops*.scala` tests. We can treat it as a baseline that fixes the immediate problem of the interaction of reach capabilities and type variables. There might be better ways to do this by using a proper adapation rule for function types instead of adding implied captures post-hoc.
- Loading branch information
Showing
22 changed files
with
200 additions
and
30 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
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,14 @@ | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/delayedRunops2.scala:10:35 ------------------------------- | ||
10 | app[List[() ->{ops*} Unit], Unit](ops, runOps) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Found: () ->{ops*} Unit | ||
| Required: () -> Unit | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/delayedRunops2.scala:18:36 ------------------------------- | ||
18 | app2[List[() => Unit], Unit](ops, runOps: List[() => Unit] -> Unit) // error | ||
| ^^^^^^ | ||
| Found: (ops: List[box () ->? Unit]^?) ->? Unit | ||
| Required: (ops: List[box () => Unit]) -> Unit | ||
| | ||
| 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,22 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps(ops: List[() => Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
def app[T, U](x: T, op: T => U): () ->{op} U = | ||
() => op(x) | ||
|
||
def unsafeRunOps(ops: List[() => Unit]): () ->{} Unit = | ||
app[List[() ->{ops*} Unit], Unit](ops, runOps) // error | ||
|
||
def app2[T, U](x: T, op: T => U): () ->{op} U = | ||
() => | ||
def y: T = x | ||
op(y) | ||
|
||
def unsafeRunOps2(ops: List[() => Unit]): () -> Unit = | ||
app2[List[() => Unit], Unit](ops, runOps: List[() => Unit] -> Unit) // 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,10 @@ | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/delayedRunops3.scala:10:41 ------------------------------- | ||
10 | app[List[() ->{ops*} Unit], Unit](ops, runOps) // error | ||
| ^^^^^^ | ||
| Found: (ops: List[box () ->? Unit]^?) ->? Unit | ||
| Required: (ops: List[box () ->{ops²*} Unit]) -> Unit | ||
| | ||
| where: ops is a reference to a value parameter | ||
| ops² is a parameter in method unsafeRunOps | ||
| | ||
| 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,14 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps(ops: List[() => Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
def app[T, U](x: T, op: T -> U): () ->{} U = | ||
() => op(x) | ||
|
||
def unsafeRunOps(ops: List[() => Unit]): () ->{} Unit = | ||
app[List[() ->{ops*} Unit], Unit](ops, runOps) // 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,21 @@ | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/delayedRunops4.scala:11:4 -------------------------------- | ||
11 | runOps[C]: List[() ->{C^} Unit] ->{C^} Unit) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Found: List[box () ->{C^} Unit] ->{C^} Unit | ||
| Required: List[box () ->{C^} Unit] -> Unit | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/delayedRunops4.scala:15:43 ------------------------------- | ||
15 | app[List[() ->{C^} Unit], Unit](ops, rops[C]) // error | ||
| ^^^^^^^ | ||
| Found: (ops: List[box () ->{C^} Unit]) ->{C^} Unit | ||
| Required: (ops: List[box () ->{C^} Unit]) -> Unit | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/delayedRunops4.scala:18:39 ------------------------------- | ||
18 | app[List[() ->{C^} Unit], Unit](ops, runOps) // error | ||
| ^^^^^^ | ||
| Found: (ops: List[box () ->? Unit]^?) ->? Unit | ||
| Required: (ops: List[box () ->{C^} Unit]) -> Unit | ||
| | ||
| 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,24 @@ | ||
import language.experimental.captureChecking | ||
|
||
def runOps[C^](ops: List[() ->{C^} Unit]): Unit = | ||
ops.foreach(op => op()) | ||
|
||
def app[T, U](x: T, op: T -> U): () ->{} U = | ||
() => op(x) | ||
|
||
def unsafeRunOps[C^](ops: List[() ->{C^} Unit]): () ->{} Unit = | ||
app[List[() ->{C^} Unit], Unit](ops, | ||
runOps[C]: List[() ->{C^} Unit] ->{C^} Unit) // error | ||
|
||
def unsafeRunOps2[C^](ops: List[() ->{C^} Unit]): () ->{} Unit = | ||
def rops[D^]: (ops: List[() ->{D^} Unit]) -> Unit = ??? | ||
app[List[() ->{C^} Unit], Unit](ops, rops[C]) // error | ||
|
||
def unsafeRunOps3[C^](ops: List[() ->{C^} Unit]): () ->{} Unit = | ||
app[List[() ->{C^} Unit], Unit](ops, runOps) // 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
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:10 ----------------------------------------------------------- | ||
8 | ps.map((x, y) => compose1(x, y)) // error // error | ||
| ^ | ||
|reference ps* is not included in the allowed capture set {} | ||
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? (ex$15: caps.Exists) -> A^? | ||
-- Error: tests/neg-custom-args/captures/reaches2.scala:8:13 ----------------------------------------------------------- | ||
8 | ps.map((x, y) => compose1(x, y)) // error // error | ||
| ^ | ||
|reference ps* is not included in the allowed capture set {} | ||
|of an enclosing function literal with expected type ((box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? (ex$15: caps.Exists) -> A^? | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches2.scala:8:10 -------------------------------------- | ||
8 | ps.map((x, y) => compose1(x, y)) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|Found: (x$1: (box (x$0: A^?) ->? (ex$18: caps.Exists) -> A^?, box (x$0: A^?) ->? (ex$19: caps.Exists) -> A^?)^?) ->? | ||
| box (x$0: A^?) ->? A^? | ||
|Required: (x$1: (box A ->{ps*} A, box A ->{ps*} A)) -> box (x$0: A^?) ->? A^? | ||
| | ||
| 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
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