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.
Avoid using
Range
s in exact substitutions (scala#17532)
- Loading branch information
Showing
2 changed files
with
50 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import language.experimental.captureChecking | ||
import caps.* | ||
|
||
trait Ref[T] { def set(x: T): T } | ||
def test() = { | ||
|
||
def swap[T](x: Ref[T]^)(y: Ref[T]^{x}): Unit = ??? | ||
def foo[T](x: Ref[T]^): Unit = | ||
swap(x)(x) | ||
|
||
def bar[T](x: () => Ref[T]^)(y: Ref[T]^{x}): Unit = | ||
swap(x())(y) // error | ||
|
||
def baz[T](x: Ref[T]^)(y: Ref[T]^{x}): Unit = | ||
swap(x)(y) | ||
} | ||
|
||
trait IO | ||
type Op = () -> Unit | ||
def test2(c: IO^, f: Op^{c}) = { | ||
def run(io: IO^)(op: Op^{io}): Unit = op() | ||
run(c)(f) | ||
|
||
def bad(getIO: () => IO^, g: Op^{getIO}): Unit = | ||
run(getIO())(g) // error | ||
} | ||
|
||
def test3() = { | ||
def run(io: IO^)(op: Op^{io}): Unit = ??? | ||
val myIO: IO^ = ??? | ||
val myOp: Op^{myIO} = ??? | ||
run(myIO)(myOp) | ||
} |