-
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.
Follow upper bounds of type variables when computing dcs
- Loading branch information
Showing
9 changed files
with
79 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-- Error: tests/neg-custom-args/captures/dcs-tvar.scala:6:15 ----------------------------------------------------------- | ||
6 | () => runOps(xs) // error | ||
| ^^ | ||
| reference xs* is not included in the allowed capture set {} | ||
| of an enclosing function literal with expected type () -> Unit | ||
-- Error: tests/neg-custom-args/captures/dcs-tvar.scala:9:15 ----------------------------------------------------------- | ||
9 | () => runOps(xs) // error | ||
| ^^ | ||
| reference xs* is not included in the allowed capture set {} | ||
| of an enclosing function literal with expected type () -> Unit |
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,9 @@ | ||
import caps.use | ||
|
||
def runOps(@use xs: List[() => Unit]): Unit = ??? | ||
|
||
def f[T <: List[() => Unit]](xs: T): () -> Unit = | ||
() => runOps(xs) // error | ||
|
||
def g[T <: List[U], U <: () => Unit](xs: T): () -> Unit = | ||
() => runOps(xs) // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class IO | ||
|
||
def f(xs: List[() => Unit]): () => Unit = () => | ||
println(xs.head) // error | ||
|
||
def test(io: IO^)(ys: List[() ->{io} Unit]) = | ||
val x = () => | ||
val z = f(ys) | ||
z() | ||
val _: () -> Unit = x // !!! ys* gets lost | ||
() | ||
|
||
def test(io: IO^) = | ||
def ys: List[() ->{io} Unit] = ??? | ||
val x = () => | ||
val z = f(ys) | ||
z() | ||
val _: () -> Unit = x // !!! io gets lost | ||
() | ||
|
||
|
||
|
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 caps.use | ||
|
||
def test(io: Object^, async: Object^) = | ||
|
||
trait A: | ||
def f(@use x: List[() ->{io} Unit]): Unit | ||
|
||
class B extends A: | ||
def f(@use x: List[() => Unit]): Unit = // error, would be unsound if allowed | ||
x.foreach(_()) | ||
|
||
class C extends A: | ||
def f(@use x: List[() ->{io, async} Unit]): Unit = // error, this one could be soundly allowed actually | ||
x.foreach(_()) | ||
|
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,13 @@ | ||
import language.experimental.captureChecking | ||
import caps.Capability | ||
|
||
trait File extends Capability | ||
|
||
class Resource[T <: Capability](gen: T): | ||
def use[U](f: T => U): U = | ||
f(gen) // OK, was error under unsealed | ||
|
||
@main def run = | ||
val myFile: File = ??? | ||
val r = Resource(myFile) // error | ||
() |