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

Improve Subtyping and Normalization of Capture Sets #22103

Open
bracevac opened this issue Dec 3, 2024 · 0 comments · May be fixed by #22183
Open

Improve Subtyping and Normalization of Capture Sets #22103

bracevac opened this issue Dec 3, 2024 · 0 comments · May be fixed by #22183
Assignees
Labels
area:experimental:cc Capture checking related itype:bug

Comments

@bracevac
Copy link
Contributor

bracevac commented Dec 3, 2024

Compiler version

Latest nightly

Minimized code

As noted in PR #22000, some expected subtyping
relations are still not supported.

import language.experimental.captureChecking

abstract class Source[+T, Cap^]:
  def transformValuesWith[U](f: (T -> U)^{Cap^}): Source[U, Cap]^{this, f} = ???

def race[T, Cap^](sources: Source[T, Cap]^{Cap^}*): Source[T, Cap]^{Cap^} = ???

def either[T1, T2, Cap^](
    src1: Source[T1, Cap]^{Cap^},
    src2: Source[T2, Cap]^{Cap^}): Source[Either[T1, T2], Cap]^{Cap^} =
  val left = src1.transformValuesWith(Left(_))
  val right = src2.transformValuesWith(Right(_))
  race(left, right) // <- rejected
  //race[Either[T1, T2], Cap](left, right) // <- accepted

Expectation

The last line should not require explicit type arguments. This appears to be caused
by not being able to conclude Cap <: CapSet^{Cap^}, but both sides
are morally equivalent.

@bracevac bracevac added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 3, 2024
@bracevac bracevac self-assigned this Dec 3, 2024
@bracevac bracevac added area:experimental:cc Capture checking related and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 3, 2024
@bracevac bracevac linked a pull request Dec 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:experimental:cc Capture checking related itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant