仓库指标
- Star
- (6,247 star)
- PR 合并指标
- (平均合并 18天 14小时) (30 天内合并 133 个 PR)
描述
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.