-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
70 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import caps.* | ||
|
||
class IO | ||
|
||
case class File(io: IO^) | ||
|
||
def test(io1: IO^, io2: IO^) = | ||
def f[C >: CapSet^{io1} <: CapSet^](file: File^{C^}) = ??? | ||
val f1: File^{io1} = ??? | ||
val f2: File^{io2} = ??? | ||
val f3: File^{io1, io2} = ??? | ||
f[CapSet^{io1}](f1) | ||
f[CapSet^{io1}](f2) // error | ||
f[CapSet^{io1}](f3) // error | ||
f[CapSet^{io2}](f2) // error | ||
f[CapSet^{io1, io2}](f1) | ||
f[CapSet^{io1, io2}](f2) | ||
f[CapSet^{io1, io2}](f3) |
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,25 @@ | ||
import caps.* | ||
|
||
trait Foo extends Capability | ||
|
||
trait CaptureSet: | ||
type C <: CapSet^ | ||
|
||
def capturePoly[C^](a: Foo^{C^}): Foo^{C^} = a | ||
def capturePoly2(c: CaptureSet)(a: Foo^{c.C^}): Foo^{c.C^} = a | ||
|
||
def test = | ||
val x: Foo^ = ??? | ||
val y: Foo^ = ??? | ||
|
||
object X extends CaptureSet: | ||
type C = CapSet^{x} | ||
|
||
val z1: Foo^{X.C^} = x | ||
val z2: Foo^{X.C^} = y // error | ||
|
||
val z3: Foo^{x} = capturePoly(x) | ||
val z4: Foo^{x} = capturePoly(y) // error | ||
|
||
val z5: Foo^{x} = capturePoly2(X)(x) | ||
val z6: Foo^{x} = capturePoly2(X)(y) // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import caps.* | ||
|
||
trait AbstractWrong: | ||
type C <: CapSet | ||
def boom(): Unit^{C^} // error | ||
|
||
trait Abstract: | ||
type C <: CapSet^ | ||
def boom(): Unit^{C^} | ||
|
||
class Concrete extends Abstract: | ||
type C = Nothing | ||
def boom() = () // error | ||
|