Skip to content

lost type information after two type projections #3443

Closed
@scabug

Description

@scabug

I have a trait for a type-level function:

trait TFn1[I, O] {
  type app[i <: I] <: O
}

and I'm trying to write bind/flatMap for it. The following is a simplified example that gives me the error I'm getting:

trait TFn1B[T] {
  type x[a, b, f <: TFn1[a, TFn1[T, b]] ] =
    TFn1[T, b] {
      type app[s <: T] = f#app[a]#app[s]
    }
}

The error is:

type arguments [s] do not conform to type app's type parameter bounds [i <: I]
           TFn1[T, b] {
           ^

I think the error message is for the app[s] part despite where ^ points. It looks like scalac doesn't know that:

  f#app[a] <: TFn1[T, b]

which should mean that s <: I since I is T and s <: T.

It seems to me that the code should be accepted but maybe some type information gets lost with the second projection.

This is in 2.8.0.RC2. As Eric Willigers pointed out on the mailing list, this code is accepted in 2.7.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions