-
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.
Add @unboxed to failing tests and standard library file Buffer.scala
- Loading branch information
Showing
15 changed files
with
105 additions
and
44 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
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,32 @@ | ||
import language.experimental.captureChecking | ||
import caps.unboxed | ||
|
||
// Some capabilities that should be used locally | ||
trait Async: | ||
// some method | ||
def read(): Unit | ||
def usingAsync[X](op: Async^ => X): X = ??? | ||
|
||
case class Box[+T](get: T) | ||
|
||
def useBoxedAsync(@unboxed x: Box[Async^]): Unit = | ||
val t0 = x | ||
val t1 = t0.get // ok | ||
t1.read() | ||
|
||
def useBoxedAsync1(@unboxed x: Box[Async^]): Unit = x.get.read() // ok | ||
|
||
def test(): Unit = | ||
|
||
val f: Box[Async^] => Unit = (x: Box[Async^]) => useBoxedAsync(x) // error | ||
val _: Box[Async^] => Unit = useBoxedAsync(_) // error | ||
val _: Box[Async^] => Unit = useBoxedAsync // error | ||
val _ = useBoxedAsync(_) // error | ||
val _ = useBoxedAsync // error | ||
|
||
def boom(x: Async^): () ->{f} Unit = | ||
() => f(Box(x)) | ||
|
||
val leaked = usingAsync[() ->{f} Unit](boom) | ||
|
||
leaked() // scope violation |
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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import language.experimental.captureChecking | ||
import caps.unboxed | ||
|
||
trait Cap: | ||
def use: Int = 42 | ||
|
||
def test2(cs: List[Cap^]): Unit = | ||
def test2(@unboxed cs: List[Cap^]): Unit = | ||
val t0: Cap^{cs*} = cs.head // error | ||
var t1: Cap^{cs*} = cs.head // error | ||
var t1: Cap^{cs*} = cs.head // 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 |
---|---|---|
@@ -1,9 +1,22 @@ | ||
import language.experimental.captureChecking | ||
import caps.unboxed | ||
|
||
class Box[T](items: Seq[T^]): | ||
def getOne: T^{items*} = ??? | ||
|
||
object Box: | ||
def getOne[T](items: Seq[T^]): T^{items*} = | ||
def getOne[T](@unboxed items: Seq[T^]): T^{items*} = | ||
val bx = Box(items) | ||
bx.getOne | ||
bx.getOne | ||
/* | ||
def head[T](items: Seq[T^]): Unit = | ||
val is = items | ||
val x = is.head | ||
() | ||
def head2[X^, T](items: Seq[T^{X^}]): T^{X^} = | ||
items.head | ||
def head3[T](items: Seq[T^]): Unit = | ||
head2[caps.CapSet^{items*}, T](items) | ||
*/ |