Skip to content

Cannot create curried dependent functions #12211

Closed
@TomasMikula

Description

@TomasMikula

Compiler version

3.0.0-RC3

Minimized code

def fst[A, B[_]]: (a: A) => (b: B[a.type]) => a.type =
  (a: A) => (b: B[a.type]) => a

def snd[A, B[_]]: (a: A) => (b: B[a.type]) => b.type =
  (a: A) => (b: B[a.type]) => b

Output

-- [E007] Type Mismatch Error: test.scala:2:12 ---------------------------------
2 |  (a: A) => (b: B[a.type]) => a
  |            ^^^^^^^^^^^^^^^^^^^
  |          Found:    B[(a : A)] => A
  |          Required: (b: Nothing) => A & (b: B[(a : A)]) => (a : A)
  |
  |          where:    B is a type in method fst with bounds <: [_$1] =>> Any

longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: test.scala:5:12 ---------------------------------
5 |  (a: A) => (b: B[a.type]) => b
  |            ^^^^^^^^^^^^^^^^^^^
  |          Found:    B[(a : A)] => B[(a : A)]
  |          Required: (b: Nothing) => Any & (b: B[(a : A)]) => b.type
  |
  |          where:    B is a type in method snd with bounds <: [_$2] =>> Any

longer explanation available when compiling with `-explain`
2 errors found

Expectation

The code should compile, as the bodies conform to the type signatures.

Also, I haven't found any way of creating an instance of a dependent function type like (a: A) => (b: B[a.type]) => a.type above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions