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

Using abstract types to encode explicit capture polymorphism fails #21869

Closed
bracevac opened this issue Oct 31, 2024 · 0 comments
Closed

Using abstract types to encode explicit capture polymorphism fails #21869

bracevac opened this issue Oct 31, 2024 · 0 comments
Labels
area:experimental:cc Capture checking related itype:bug

Comments

@bracevac
Copy link
Contributor

bracevac commented Oct 31, 2024

Compiler version

Latest NIGHTLY.

Minimized code

import language.experimental.captureChecking
import caps._

trait Foo extends Capability

trait CaptureSet:
  type C <: CapSet^

def capturePoly[C^](x: Foo^{C^}): Foo^{C^} = x
def capturePoly2(c: CaptureSet)(x: Foo^{c.C^}): Foo^{c.C^} = x

def test =
  val x: Foo^ = ???

  object X extends CaptureSet:
    type C = CapSet^{x}

  val y: Foo^{x} = capturePoly(x)     // ok
  val z: Foo^{x} = capturePoly2(X)(x) // error

Output

-- [E007] Type Mismatch Error: local/ccpaths.scala:19:35 -----------------------
19 |  val z: Foo^{x} = capturePoly2(X)(x)
   |                                   ^
   |                                   Found:    (x : Foo^)
   |                                   Required: Foo^{c.C^}
   |
   | longer explanation available when compiling with `-explain`

Expectation

It should be accepted.

@bracevac bracevac added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label area:experimental:cc Capture checking related and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 31, 2024
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

No branches or pull requests

1 participant