Skip to content

Partial application of bounded type operator fails bounds check #9695

Open
@sstucki

Description

@sstucki

There seems to be some inconsistency between curried and uncurried type operators. This means that partially applying certain operators fails.

Minimized code

object Test {
  type Foo[+A, +B <: A] = B               // uncurried -> OK
  type Bar[+A] = [B <: A] =>> Foo[A, B]   // curried   -> fails
}

Output

-- Error: CurryingOps.scala:3:12 -----------------------------------------------
3 |  type Bar[+A] = [B <: A] =>> Foo[A, B]   // curried   -> fails
  |           ^^
  |covariant type parameter A occurs in contravariant position in [B <: A] =>> Test.Foo[A, B]
1 error found

Expectation

I'd expect the two versions to behave the same. The definition of Foo is correct, IMO. The type A does not appear in a contravariant position inside the definition/body of Foo — in fact it doesn't appear at all. It does appear in a bound in the signature of Foo but that shouldn't matter (the signature is not part of the definition). That means that the error in Bar is probably a false negative. I'm not sure why the bounds of type lambdas are considered in variance checking.

This may or may not be related to #6320 and #6499.

Tagging @Blaisorblade and @smarter since the example resulted from a discussion we had about variance checking.

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