Skip to content

Using abstract types to encode explicit capture polymorphism fails #21869

Closed
@bracevac

Description

@bracevac

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions