Skip to content

Commit 7f0a902

Browse files
authored
Some additions and changes in tests (#17327)
2 parents ccf38be + 7576fbe commit 7f0a902

File tree

5 files changed

+88
-2
lines changed

5 files changed

+88
-2
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import language.experimental.captureChecking
2+
import compiletime.uninitialized
3+
4+
class File:
5+
def write(x: String): Unit = ???
6+
7+
class Service:
8+
var file: {*} File = uninitialized
9+
def log = file.write("log") // error
10+
11+
def withFile[T](op: (f: {*} File) => T): T =
12+
op(new File)
13+
14+
def test =
15+
withFile: f =>
16+
val o = Service()
17+
o.file = f
18+
o.log

tests/pending/pos/i16826.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import language.experimental.captureChecking
2+
class A
3+
class B(a: {*} A)
4+
class C(a: {*} A):
5+
def setB(b: {a} B): Unit = ???
6+
7+
8+
def test(a1: {*} A)(b1: {a1} B) =
9+
val c = new C(a1)
10+
c.setB(b1)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import language.experimental.captureChecking
2+
import annotation.capability
3+
import compiletime.uninitialized
4+
5+
object test1:
6+
class File:
7+
def write(x: String): Unit = ???
8+
9+
class Service(f: {*} File):
10+
def log = f.write("log")
11+
12+
def withFile[T](op: (f: {*} File) => T): T =
13+
op(new File)
14+
15+
def test =
16+
withFile: f =>
17+
val o = Service(f)
18+
o.log
19+
20+
object test2:
21+
@capability class IO
22+
23+
class File:
24+
def write(x: String): Unit = ???
25+
26+
class Service(io: IO):
27+
var file: {io} File = uninitialized
28+
def log = file.write("log")
29+
30+
def withFile[T](io: IO)(op: (f: {io} File) => T): T =
31+
op(new File)
32+
33+
def test(io: IO) =
34+
withFile(io): f =>
35+
val o = Service(io)
36+
o.file = f
37+
o.log
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import language.experimental.captureChecking
2+
import annotation.{capability, constructorOnly}
3+
4+
@capability class IO
5+
class Blah
6+
class Pkg(using @constructorOnly io: IO):
7+
class Foo:
8+
def m(foo: {io} Blah) = ???
9+
class Pkg2(using io: IO):
10+
class Foo:
11+
def m(foo: {io} Blah): Any = io; ???
12+
13+
def main(using io: IO) =
14+
val pkg = Pkg()
15+
val f = pkg.Foo()
16+
f.m(???)
17+
val pkg2 = Pkg2()
18+
val f2 = pkg2.Foo()
19+
f2.m(???)
20+
21+

tests/run/errorhandling/Result.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ object Result:
2929
case err: Err[_] => err
3030

3131
/** Validate both `r` and `other`; return a pair of successes or a list of failures. */
32-
def * [U](other: Result[U, E]): Result[(T, U), List[E]] = (r, other) match
32+
def zip[U](other: Result[U, E]): Result[(T, U), List[E]] = (r, other) match
3333
case (Ok(x), Ok(y)) => Ok((x, y))
3434
case (Ok(_), Err(e)) => Err(e :: Nil)
3535
case (Err(e), Ok(_)) => Err(e :: Nil)
3636
case (Err(e1), Err(e2)) => Err(e1 :: e2 :: Nil)
3737

3838
/** Validate both `r` and `other`; return a tuple of successes or a list of failures.
39-
* Unlike with `*`, the right hand side `other` must be a `Result` returning a `Tuple`,
39+
* Unlike with `zip`, the right hand side `other` must be a `Result` returning a `Tuple`,
4040
* and the left hand side is added to it. See `Result.empty` for a convenient
4141
* right unit of chains of `*:`s.
4242
*/

0 commit comments

Comments
 (0)