Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
odersky opened this issue Apr 18, 2024 · 0 comments · Fixed by #20232
Closed

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

odersky opened this issue Apr 18, 2024 · 0 comments · Fixed by #20232
Assignees
Labels
cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug
Milestone

Comments

@odersky
Copy link
Contributor

odersky commented Apr 18, 2024

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

@odersky odersky added the stat:needs triage Every issue needs to have an "area" and "itype" label label Apr 18, 2024
@odersky odersky self-assigned this Apr 18, 2024
@odersky odersky added cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 18, 2024
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 18, 2024
Suppress the creation of apply methods for these arguments

Fixes scala#20231
odersky added a commit that referenced this issue Apr 18, 2024
Suppress the creation of apply method selections for these arguments

Fixes #20231
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cc-experiment Intended to be merged with cc-experiment branch on origin itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants