-
Couldn't load subscription status.
- Fork 1.1k
Closed
Labels
cc-experimentIntended to be merged with cc-experiment branch on originIntended to be merged with cc-experiment branch on originitype:bug
Milestone
Description
Compiler version
main branch
Minimized code
It is modified from the test case pos-custom-args/captures/lazyref.scala.
@annotation.capability class Cap class LazyRef[T](val elem: () => T): val get: {elem} () -> T = elem def map[U](f: T => U): {f, this} LazyRef[U] = new LazyRef(() => f(elem())) def map[A, B](ref: {*} LazyRef[A], f: A => B): {f, ref} LazyRef[B] = new LazyRef(() => f(ref.elem())) def main(io: Cap) = { def mapd[A, B]: ({io} LazyRef[A], A => B) => {*} LazyRef[B] = (ref1, f1) => map[A, B](ref1, f1) }Output
-- [E007] Type Mismatch Error: issues/lazymap-avoid.scala:13:4 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 13 | (ref1, f1) => map[A, B](ref1, f1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Found: ? (ref1: {io} Nothing, f1: ? (x$0: ? A) -> ? B) -> {f1, ref1, io} LazyRef[? >: ? B <: ? B]{elem: {*} () -> box ? B} | Required: ({io} LazyRef[A], A => B) => {io} LazyRef[B] | | longer explanation available when compiling with `-explain` 1 error foundExpectation
It should compile.
Trace of the avoidance call in recheckBlock during rechecking:
==> TypeOps.avoid(? (ref1: ? LazyRef[? A]{elem: ? () -> box ? A}, f1: ? (x$0: ? A) -> ? B) -> {f1, ref1} LazyRef[? B]{elem: {*} () -> box ? B}, [method $anonfun])? <== TypeOps.avoid(? (ref1: ? LazyRef[? A]{elem: ? () -> box ? A}, f1: ? (x$0: ? A) -> ? B) -> {f1, ref1} LazyRef[? B]{elem: {*} () -> box ? B}, [method $anonfun]) = ? (ref1: ? Nothing, f1: ? (x$0: ? A) -> ? B) -> {f1, ref1} LazyRef[? >: ? B <: ? B]{elem: {*} () -> box ? B} As seen here, during avoidance, the capability argument type becomes Nothing.
Metadata
Metadata
Assignees
Labels
cc-experimentIntended to be merged with cc-experiment branch on originIntended to be merged with cc-experiment branch on originitype:bug