File tree Expand file tree Collapse file tree 7 files changed +27
-21
lines changed
compiler/src/dotty/tools/dotc/cc
tests/neg-custom-args/captures Expand file tree Collapse file tree 7 files changed +27
-21
lines changed Original file line number Diff line number Diff line change @@ -693,7 +693,7 @@ object Capabilities:
693693 thisMap =>
694694
695695 override def apply (t : Type ) =
696- if variance <= 0 then t
696+ if variance < 0 then t
697697 else t match
698698 case t @ CapturingType (_, _) =>
699699 mapOver(t)
@@ -703,6 +703,8 @@ object Capabilities:
703703 this (CapturingType (parent1, ann.tree.toCaptureSet))
704704 else
705705 t.derivedAnnotatedType(parent1, ann)
706+ case t @ FunctionOrMethod (_, _) if t.isAliasFun =>
707+ t // stop at dependent function types
706708 case _ =>
707709 mapFollowingAliases(t)
708710
Original file line number Diff line number Diff line change 33 | ^
44 | Type argument test.Tree^ does not conform to upper bound test.Tree in inferred type test.C[test.Tree^]
55 |
6- | where: ^ refers to the universal root capability
6+ | where: ^ refers to a fresh root capability in the type of value foo
77 |
88 | longer explanation available when compiling with `-explain`
99-- [E057] Type Mismatch Error: tests/neg-custom-args/captures/boundschecks3.scala:10:11 --------------------------------
101010 | type T = C[Tree^] // error
1111 | ^
1212 | Type argument test.Tree^ does not conform to upper bound test.Tree in inferred type test.C[test.Tree^]
1313 |
14- | where: ^ refers to the universal root capability
14+ | where: ^ refers to a fresh root capability in the type of type T
1515 |
1616 | longer explanation available when compiling with `-explain`
1717-- [E057] Type Mismatch Error: tests/neg-custom-args/captures/boundschecks3.scala:11:11 --------------------------------
Original file line number Diff line number Diff line change 1- -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:8:10 -------------------------------
2- 8 | x.value(cap => cap.use()) // error, was OK
3- | ^^^^^^^^^^^^^^^^
4- | Found: (cap: Cap^?) => Int
5- | Required: Cap^ =>² Int
6- |
7- | where: => refers to the universal root capability
8- | =>² refers to a fresh root capability created in method test1
9- | ^ refers to the universal root capability
10- |
11- | longer explanation available when compiling with `-explain`
121-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/box-adapt-cases.scala:15:10 ------------------------------
13215 | x.value(cap => cap.use()) // error
143 | ^^^^^^^^^^^^^^^^
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ def test1(): Unit = {
55 class Id [X ](val value : [T ] -> (op : X => T ) -> T )
66
77 val x : Id [Cap ^ ] = ???
8- x.value(cap => cap.use()) // error, was OK
8+ x.value(cap => cap.use())
99}
1010
1111def test2 (io : Cap ^ ): Unit = {
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg-custom-args/captures/class-level-attack.scala:12:24 ------------------------------------------------
2+ 12 | val r: Ref[IO^] = Ref[IO^](io) // error:
3+ | ^^^
4+ | Type variable X of constructor Ref cannot be instantiated to IO^ since
5+ | that type captures the root capability `cap`.
6+ |
7+ | where: ^ refers to the universal root capability
8+ -- [E007] Type Mismatch Error: tests/neg-custom-args/captures/class-level-attack.scala:17:26 ---------------------------
9+ 17 | def set(x: IO^) = r.put(x) // error
10+ | ^
11+ | Found: IO^{x}
12+ | Required: IO^
13+ |
14+ | where: ^ refers to a fresh root capability in the type of value r
15+ |
16+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change @@ -13,9 +13,8 @@ class C(io: IO^):
1313 // Type variable X of constructor Ref cannot be instantiated to box IO^ since
1414 // that type captures the root capability `cap`.
1515 // where: ^ refers to the universal root capability
16- val r2 : Ref [IO ^ ] = Ref (io) // error:
17- // Error: Ref[IO^{io}] does not conform to Ref[IO^] (since Refs are invariant)
18- def set (x : IO ^ ) = r.put(x)
16+ val r2 : Ref [IO ^ ] = Ref (io)
17+ def set (x : IO ^ ) = r.put(x) // error
1918
2019def outer (outerio : IO ^ ) =
2120 val c = C (outerio)
Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ def usingIO[T](op: IO => T): T = ???
66class Wrapper [T ](val value : [R ] -> (f : T => R ) -> R )
77def mk [T ](x : T ): Wrapper [T ] = Wrapper ([R ] => f => f(x))
88def useWrappedIO (wrapper : Wrapper [IO ]): () -> Unit =
9- () =>
10- wrapper.value: io => // error
9+ () => // error
10+ wrapper.value: io =>
1111 io.brewCoffee()
1212def main (): Unit =
13- val escaped = usingIO(io => useWrappedIO(mk(io))) // error
13+ val escaped = usingIO(io => useWrappedIO(mk(io)))
1414 escaped() // boom
You can’t perform that action at this time.
0 commit comments