Skip to content

Capture set inference interacts problematically with inferred impure type variables #18881

Closed
@Linyxus

Description

@Linyxus

Compiler version

main

Minimized code

import language.experimental.captureChecking

trait Resource
def id[X](x: X): x.type = x
def foo[M <: Resource](r: M^) = id(r)

Output

-- [E007] Type Mismatch Error: issues/cc-setup-impure-classes.scala:5:35 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
5 |def foo[M <: Resource](r: M^) = id(r)
  |                                   ^
  |                                   Found:    (r : M^)
  |                                   Required: M
  |
  | longer explanation available when compiling with `-explain`
1 error found

Expectation

It should work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions