Skip to content

Capture references in @retains annotation cannot be context functions #20231

Closed
@odersky

Description

@odersky

Compiler version

3.5-RC1

Minimized example

class Async
class C(val x: Async ?=> Unit)
def foo(x: Async ?=> Unit): C^{x} = C(x)
def foo(x: Async ?=> Unit)(using Async): C^{x} = C(x)

Output

-- [E172] Type Error: cfun-capturerefs.scala:3:32 ------------------------------
3 |def foo(x: Async ?=> Unit): C^{x} = C(x)
  |                                ^
  |No given instance of type Async was found for parameter of (Async) ?=> Unit
  |Where (Async) ?=> Unit is an alias of: (Async) ?=> Unit
-- Error: cfun-capturerefs.scala:4:44 ------------------------------------------
4 |def foo(x: Async ?=> Unit)(using Async): C^{x} = C(x)
  |                                            ^
  |                x.apply(x$2): Unit is not a legal element of a capture set

Expectation

Should compile

Metadata

Metadata

Assignees

Labels

cc-experimentIntended to be merged with cc-experiment branch on originitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions