Dotty: Ignored upper bound of type parameter

Created on 19 Jul 2017  路  3Comments  路  Source: lampepfl/dotty

In scala/collection-strawman, this line gives the following compilation error:

~
def removeAll(keys: IterableOnce[K]): C = fromSpecificIterable(keys.iterator().foldLeftCC[K, V](_ - _))
^^^
value - is not a member of CC[K, V]
~

Though CC is upper bounded by MapOps (see here), which provides the - operation. Note that the CC upper bound is recursive.

This code compiles fine with Scala 2.12 and 2.13.

typer advanced bug

All 3 comments

Here is a self-contained reduced test case: https://scastie.scala-lang.org/mlfhyDXKRDasi6imUSbFfw

Not only CC is F-bounded, but we also have the C type parameter which is upper bounded by CC.

Though type C is not involved in the expression that raises the type error, if I remove it from Foo definition then the error disappears.

A beauty! Yet another nasty interaction between F-bounds and higher kinded types.

Was this page helpful?
0 / 5 - 0 ratings