-
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.
First implementation of capture polymorphism
- Loading branch information
Showing
16 changed files
with
141 additions
and
29 deletions.
There are no files selected for viewing
Submodule specs2
updated
1 files
+6 −3 | core/shared/src/test/scala/org/specs2/matcher/TypecheckSpec.scala |
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
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,23 @@ | ||
import language.experimental.captureChecking | ||
import annotation.experimental | ||
import caps.{CapSet, Capability} | ||
|
||
@experimental object Test: | ||
|
||
class C extends Capability | ||
class D | ||
|
||
def f[X^](x: D^{X^}): D^{X^} = x | ||
def g[X^](x: D^{X^}, y: D^{X^}): D^{X^} = x | ||
|
||
def test(c1: C, c2: C) = | ||
val d: D^{c1, c2} = D() | ||
val x = f[CapSet^{c1, c2}](d) | ||
val _: D^{c1, c2} = x | ||
val d1: D^{c1} = D() | ||
val d2: D^{c2} = D() | ||
val y = g(d1, d2) | ||
val _: D^{d1, d2} = y | ||
val _: D^{c1, c2} = y | ||
|
||
|
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,36 @@ | ||
import language.experimental.captureChecking | ||
import annotation.experimental | ||
import caps.{CapSet, Capability} | ||
|
||
@experimental object Test: | ||
|
||
class Label //extends Capability | ||
|
||
class Listener | ||
|
||
class Source[X^]: | ||
private var listeners: Set[Listener^{X^}] = Set.empty | ||
def register(x: Listener^{X^}): Unit = | ||
listeners += x | ||
|
||
def allListeners: Set[Listener^{X^}] = listeners | ||
|
||
def test1(lbl1: Label^, lbl2: Label^) = | ||
val src = Source[CapSet^{lbl1, lbl2}] | ||
def l1: Listener^{lbl1} = ??? | ||
val l2: Listener^{lbl2} = ??? | ||
src.register{l1} | ||
src.register{l2} | ||
val ls = src.allListeners | ||
val _: Set[Listener^{lbl1, lbl2}] = ls | ||
|
||
def test2(lbls: List[Label^]) = | ||
def makeListener(lbl: Label^): Listener^{lbl} = ??? | ||
val listeners = lbls.map(makeListener) | ||
val src = Source[CapSet^{lbls*}] | ||
for l <- listeners do | ||
src.register(l) | ||
val ls = src.allListeners | ||
val _: Set[Listener^{lbls*}] = ls | ||
|
||
|