forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dealias type before checking reach refinements
- Loading branch information
Showing
3 changed files
with
26 additions
and
1 deletion.
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,5 @@ | ||
-- Error: tests/neg/unsound-reach-4.scala:20:19 ------------------------------------------------------------------------ | ||
20 | escaped = boom.use(f) // error | ||
| ^^^^^^^^ | ||
| Reach capability backdoor* and universal capability cap cannot both | ||
| appear in the type (x: F): box File^{backdoor*} of this expression |
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,20 @@ | ||
import language.experimental.captureChecking | ||
trait File: | ||
def close(): Unit | ||
|
||
def withFile[R](path: String)(op: File^ => R): R = ??? | ||
|
||
type F = File^ | ||
|
||
trait Foo[+X]: | ||
def use(x: F): X | ||
class Bar extends Foo[File^]: | ||
def use(x: F): File^ = x | ||
|
||
def bad(): Unit = | ||
val backdoor: Foo[File^] = new Bar | ||
val boom: Foo[File^{backdoor*}] = backdoor | ||
|
||
var escaped: File^{backdoor*} = null | ||
withFile("hello.txt"): f => | ||
escaped = boom.use(f) // error |