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.
Capture set healing happens at the end of capture checking (in the `postCheck` function), which checks the capture set in each type argument and widen the ill-formed `TermParamRef`s by widening them. However, it is possible that a capture set is healed first, and then get a `TermParamRef` propagated into it later when we are healing another capture set. This lead to unsoundness. This commit installs an handler on capture sets when healing them and will inspect the newly added elements and heal these new elements as well.
- Loading branch information
Showing
6 changed files
with
50 additions
and
11 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,7 @@ | ||
-- Error: tests/neg-custom-args/captures/usingLogFile-alt.scala:18:2 --------------------------------------------------- | ||
18 | usingFile( // error | ||
| ^^^^^^^^^ | ||
| Sealed type variable T cannot be instantiated to box () => Unit since | ||
| that type captures the root capability `cap`. | ||
| This is often caused by a local capability in the body of method usingFile | ||
| leaking as part of its result. |
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,23 @@ | ||
// Reported in issue #17517 | ||
|
||
import language.experimental.captureChecking | ||
import java.io.* | ||
|
||
object Test: | ||
class Logger(f: OutputStream^): | ||
def log(msg: String): Unit = ??? | ||
|
||
def usingFile[sealed T](name: String, op: OutputStream^ => T): T = | ||
val f = new FileOutputStream(name) | ||
val result = op(f) | ||
f.close() | ||
result | ||
|
||
def usingLogger[sealed T](f: OutputStream^)(op: Logger^{f} => T): T = ??? | ||
|
||
usingFile( // error | ||
"foo", | ||
file => { | ||
usingLogger(file)(l => () => l.log("test")) | ||
} | ||
) |
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