-
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.
Make reach refinement shallow (#19171)
This is to address the following soundness issue: ```scala trait File val useFile: [R] -> (path: String) -> (op: File^ -> R) -> R = ??? def main(): Unit = val f: [R] -> (path: String) -> (op: File^ -> R) -> R = useFile val g: [R] -> (path: String) -> (op: File^{f*} -> R) -> R = f // should be an error val leaked = g[File^{f*}]("test")(f => f) // boom ```
- Loading branch information
Showing
3 changed files
with
73 additions
and
16 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,18 @@ | ||
import language.experimental.captureChecking | ||
trait IO | ||
def test1(): Unit = | ||
val f: IO^ => IO^ = x => x | ||
val g: IO^ => IO^{f*} = f // error | ||
def test2(): Unit = | ||
val f: [R] -> (IO^ => R) -> R = ??? | ||
val g: [R] -> (IO^{f*} => R) -> R = f // error | ||
def test3(): Unit = | ||
val f: [R] -> (IO^ -> R) -> R = ??? | ||
val g: [R] -> (IO^{f*} -> R) -> R = f // error | ||
def test4(): Unit = | ||
val xs: List[IO^] = ??? | ||
val ys: List[IO^{xs*}] = xs // ok | ||
def test5(): Unit = | ||
val f: [R] -> (IO^ -> R) -> IO^ = ??? | ||
val g: [R] -> (IO^ -> R) -> IO^{f*} = f // ok | ||
val h: [R] -> (IO^{f*} -> R) -> IO^ = f // 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,8 @@ | ||
import language.experimental.captureChecking | ||
|
||
trait File | ||
val useFile: [R] -> (path: String) -> (op: File^ -> R) -> R = ??? | ||
def main(): Unit = | ||
val f: [R] -> (path: String) -> (op: File^ -> R) -> R = useFile | ||
val g: [R] -> (path: String) -> (op: File^{f*} -> R) -> R = f // error | ||
val leaked = g[File^{f*}]("test")(f => f) // boom |