forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop the scheme where we only charge the last arrow of a curried lambda with elements used in the body. On the one hand, this is unsound without compensation measures (like, restricting to reach capabilities, or taking all capture sets of a named curried function as the underlying reference). On the other hand, this should be generalized to all closures and anonymous functions forming the right hand sides of methods.
- Loading branch information
Showing
9 changed files
with
55 additions
and
83 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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
-- Error: tests/neg-custom-args/captures/leaked-curried.scala:14:20 ---------------------------------------------------- | ||
14 | () => () => io // error | ||
| ^^ | ||
|(io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} of the self type of class Fuzz | ||
| (io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} | ||
| of an enclosing function literal with expected type () -> () ->{io} (ex$7: caps.Exists) -> Cap^{ex$7} | ||
-- Error: tests/neg-custom-args/captures/leaked-curried.scala:17:20 ---------------------------------------------------- | ||
17 | () => () => io // error | ||
| ^^ | ||
|(io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} of the self type of class Foo | ||
| (io : Cap^) cannot be referenced here; it is not included in the allowed capture set {} | ||
| of an enclosing function literal with expected type () -> () ->{io} (ex$15: caps.Exists) -> Cap^{ex$15} |
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,72 +1,23 @@ | ||
import language.experimental.saferExceptions | ||
import language.experimental.erasedDefinitions | ||
|
||
class Ex1 extends Exception("Ex1") | ||
class Ex2 extends Exception("Ex2") | ||
class Ex3 extends Exception("Ex3") | ||
|
||
def foo0(i: Int): (CanThrow[Ex1], CanThrow[Ex2]) ?-> Unit = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
/* Does not work yet curried dependent CFTs are not yet handled in typer | ||
def foo01(i: Int): (ct: CanThrow[Ex1]) ?-> CanThrow[Ex2] ?->{ct} Unit = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
*/ | ||
|
||
def foo1(i: Int): Unit throws Ex1 throws Ex2 = | ||
if i > 0 then throw new Ex1 else throw new Ex1 | ||
|
||
def foo2(i: Int): Unit throws Ex1 | Ex2 = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
def foo3(i: Int): Unit throws (Ex1 | Ex2) = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
def foo4(i: Int)(using CanThrow[Ex1], CanThrow[Ex2]): Unit = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
def foo5(i: Int)(using CanThrow[Ex1])(using CanThrow[Ex2]): Unit = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
def foo6(i: Int)(using CanThrow[Ex1 | Ex2]): Unit = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
def foo7(i: Int)(using CanThrow[Ex1]): Unit throws Ex1 | Ex2 = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
/* | ||
def foo8(i: Int)(using CanThrow[Ex2]): Unit throws Ex2 | Ex1 = | ||
if i > 0 then throw new Ex1 else throw new Ex2 | ||
|
||
throw new Ex2 | ||
*/ | ||
def foo9(i: Int): Unit throws Ex1 | Ex2 | Ex3 = | ||
if i > 0 then throw new Ex1 | ||
else if i < 0 then throw new Ex2 | ||
else throw new Ex3 | ||
|
||
def test(): Unit = | ||
try | ||
foo1(1) | ||
foo2(1) | ||
foo3(1) | ||
foo4(1) | ||
foo5(1) | ||
foo6(1) | ||
foo7(1) | ||
foo8(1) | ||
catch | ||
case _: Ex1 => | ||
case _: Ex2 => | ||
|
||
try | ||
try | ||
foo1(1) | ||
foo2(1) | ||
foo3(1) | ||
foo4(1) | ||
foo5(1) | ||
// foo6(1) // As explained in the docs this won't work until we find a way to aggregate capabilities | ||
foo7(1) | ||
foo8(1) | ||
catch | ||
case _: Ex1 => | ||
catch | ||
case _: Ex2 => | ||
throw new Ex3 | ||
/* | ||
def foo9a(i: Int): | ||
(erased x$0: CanThrow[Ex3]^) ?-> (erased x$1: CanThrow[Ex2]^) ?-> | ||
(erased x$2: CanThrow[Ex1]^) ?->{x$1, x$0} Unit | ||
= | ||
(erased x3: CanThrow[Ex3]) | ||
?=> (erased x2: CanThrow[Ex2]) | ||
?=> (erased x1: CanThrow[Ex1]) | ||
?=> throw new Ex3 | ||
*/ |
This file was deleted.
Oops, something went wrong.