-
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.
Make capture sets of expressions deriving Capability explicit
When an expression has a type that derives from caps.Capability, add an explicit capture set. Also: Address other review comments
- Loading branch information
Showing
21 changed files
with
92 additions
and
50 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
22 changes: 11 additions & 11 deletions
22
tests/neg-custom-args/captures/effect-swaps-explicit.check
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,29 +1,29 @@ | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:64:8 ------------------------- | ||
63 | Result: | ||
64 | Future: // error, type mismatch | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:62:8 ------------------------- | ||
61 | Result: | ||
62 | Future: // error, type mismatch | ||
| ^ | ||
| Found: Result.Ok[box Future[box T^?]^{fr, contextual$1}] | ||
| Required: Result[Future[T], Nothing] | ||
65 | fr.await.ok | ||
63 | fr.await.ok | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from effect-swaps-explicit.scala:41 | ||
41 | boundary(Ok(body)) | ||
|This location contains code that was inlined from effect-swaps-explicit.scala:39 | ||
39 | boundary(Ok(body)) | ||
| ^^^^^^^^ | ||
-------------------------------------------------------------------------------------------------------------------- | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:74:10 ------------------------ | ||
74 | Future: fut ?=> // error: type mismatch | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:72:10 ------------------------ | ||
72 | Future: fut ?=> // error: type mismatch | ||
| ^ | ||
| Found: Future[box T^?]^{fr, lbl} | ||
| Required: Future[box T^?]^? | ||
75 | fr.await.ok | ||
73 | fr.await.ok | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:68:15 --------------------------------------------- | ||
68 | Result.make: //lbl ?=> // error, escaping label from Result | ||
-- Error: tests/neg-custom-args/captures/effect-swaps-explicit.scala:66:15 --------------------------------------------- | ||
66 | Result.make: //lbl ?=> // error, escaping label from Result | ||
| ^^^^^^^^^^^ | ||
|local reference contextual$9 from (using contextual$9: boundary.Label[Result[box Future[box T^?]^{fr, contextual$9}, box E^?]]^): | ||
| box Future[box T^?]^{fr, contextual$9} leaks into outer capture set of type parameter T of method make in object Result |
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,5 +1,3 @@ | ||
import annotation.capability | ||
|
||
object boundary: | ||
|
||
final class Label[-T] // extends caps.Capability | ||
|
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,24 +1,24 @@ | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps.scala:64:8 ---------------------------------- | ||
63 | Result: | ||
64 | Future: // error, type mismatch | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps.scala:62:8 ---------------------------------- | ||
61 | Result: | ||
62 | Future: // error, type mismatch | ||
| ^ | ||
| Found: Result.Ok[box Future[box T^?]^{fr, contextual$1}] | ||
| Required: Result[Future[T], Nothing] | ||
65 | fr.await.ok | ||
63 | fr.await.ok | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from effect-swaps.scala:41 | ||
41 | boundary(Ok(body)) | ||
|This location contains code that was inlined from effect-swaps.scala:39 | ||
39 | boundary(Ok(body)) | ||
| ^^^^^^^^ | ||
-------------------------------------------------------------------------------------------------------------------- | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps.scala:74:10 --------------------------------- | ||
74 | Future: fut ?=> // error: type mismatch | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/effect-swaps.scala:72:10 --------------------------------- | ||
72 | Future: fut ?=> // error: type mismatch | ||
| ^ | ||
| Found: Future[box T^?]^{fr, lbl} | ||
| Required: Future[box T^?]^? | ||
75 | fr.await.ok | ||
73 | fr.await.ok | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,5 +1,3 @@ | ||
import annotation.capability | ||
|
||
object boundary: | ||
|
||
final class Label[-T] extends caps.Capability | ||
|
21 changes: 21 additions & 0 deletions
21
tests/neg-custom-args/captures/extending-cap-classes.check
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,21 @@ | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/extending-cap-classes.scala:7:15 ------------------------- | ||
7 | val x2: C1 = new C2 // error | ||
| ^^^^^^ | ||
| Found: C2^ | ||
| Required: C1 | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/extending-cap-classes.scala:8:15 ------------------------- | ||
8 | val x3: C1 = new C3 // error | ||
| ^^^^^^ | ||
| Found: C3^ | ||
| Required: C1 | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/extending-cap-classes.scala:13:15 ------------------------ | ||
13 | val z2: C1 = y2 // error | ||
| ^^ | ||
| Found: (y2 : C2)^{y2} | ||
| Required: C1 | ||
| | ||
| longer explanation available when compiling with `-explain` |
14 changes: 14 additions & 0 deletions
14
tests/neg-custom-args/captures/extending-cap-classes.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class C1 | ||
class C2 extends C1, caps.Capability | ||
class C3 extends C2 | ||
|
||
def test = | ||
val x1: C1 = new C1 | ||
val x2: C1 = new C2 // error | ||
val x3: C1 = new C3 // error | ||
|
||
val y2: C2 = new C2 | ||
val y3: C3 = new C3 | ||
|
||
val z2: C1 = y2 // 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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:23:14 ------------------------------------------------------ | ||
23 | val later = usingLogFile { f => () => f.write(0) } // error | ||
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:22:14 ------------------------------------------------------ | ||
22 | val later = usingLogFile { f => () => f.write(0) } // error | ||
| ^^^^^^^^^^^^ | ||
| local reference f leaks into outer capture set of type parameter T of method usingLogFile in object Test2 | ||
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:28:23 ------------------------------------------------------ | ||
28 | private val later2 = usingLogFile { f => Cell(() => f.write(0)) } // error | ||
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:27:23 ------------------------------------------------------ | ||
27 | private val later2 = usingLogFile { f => Cell(() => f.write(0)) } // error | ||
| ^^^^^^^^^^^^ | ||
| local reference f leaks into outer capture set of type parameter T of method usingLogFile in object Test2 | ||
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:44:16 ------------------------------------------------------ | ||
44 | val later = usingFile("out", f => (y: Int) => xs.foreach(x => f.write(x + y))) // error | ||
-- Error: tests/neg-custom-args/captures/usingLogFile.scala:43:16 ------------------------------------------------------ | ||
43 | val later = usingFile("out", f => (y: Int) => xs.foreach(x => f.write(x + y))) // error | ||
| ^^^^^^^^^ | ||
| local reference f leaks into outer capture set of type parameter T of method usingFile in object Test3 |
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,5 +1,4 @@ | ||
import java.io.* | ||
import annotation.capability | ||
|
||
object Test1: | ||
|
||
|
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,4 +1,3 @@ | ||
import annotation.capability | ||
import caps.Capability | ||
|
||
def f1(c: Capability): () ->{c} c.type = () => c // ok | ||
|
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,5 +1,4 @@ | ||
import language.experimental.captureChecking | ||
import annotation.capability | ||
import caps.cap | ||
|
||
trait Ptr[A] | ||
|
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,4 +1,3 @@ | ||
import annotation.capability | ||
import annotation.constructorOnly | ||
|
||
class FileSystem extends caps.Capability | ||
|
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