-
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.
Fix the visibility check in
markFree
(#20221)
Fixes #20169. Fixes #20224. It turns out that the type argument in #20169 is properly boxed. It is just that when doing box adaptation, when charging `cap` into environments it gets discarded by the visibility check. Right now, a symbol is considered visible in an environment only when the owner of the environment is contained in the symbol. This is not right: when there is not containment relation between the symbol and the environment owner the symbol is also visible from the environment, which is the case here for `cap`.
- Loading branch information
Showing
4 changed files
with
55 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import language.experimental.captureChecking | ||
@annotation.capability | ||
class IO: | ||
def brewCoffee(): Unit = ??? | ||
def usingIO[T](op: IO => T): T = ??? | ||
|
||
type Wrapper[T] = [R] -> (f: T => R) -> R | ||
def mk[T](x: T): Wrapper[T] = [R] => f => f(x) | ||
def useWrappedIO(wrapper: Wrapper[IO]): () -> Unit = | ||
() => | ||
wrapper: io => // error | ||
io.brewCoffee() | ||
def main(): Unit = | ||
val escaped = usingIO(io => useWrappedIO(mk(io))) | ||
escaped() // boom |
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 @@ | ||
case class Box[T](x: T): | ||
def foreach(f: T => Unit): Unit = f(x) | ||
|
||
def runOps(ops: Box[() => Unit]): () -> Unit = | ||
val applyFn: (() => Unit) -> Unit = f => f() | ||
val fn: () -> Unit = () => | ||
ops.foreach(applyFn) // error | ||
fn |