Closed
Description
Minimized code
trait Measure[-C, M]
implicit object PathMeasure extends Measure[Long, (Int, Long)]
object FingerTree {
def empty[V, A](implicit m: Measure[A, V]): FingerTree[V, A] = ???
}
trait FingerTree[V, +A] {
def :+[A1 >: A](b: A1)(implicit m: Measure[A1, V]): FingerTree[V, A1]
}
trait Test {
def readPathComponent(): Long
def read(sz: Int): Any = {
var tree = FingerTree.empty(PathMeasure) // problem origin
var i = 0
while (i < sz) {
tree = tree :+ readPathComponent() // problem shows here
i += 1
}
???
}
}
Output
In the line 'problem shows here':
Found: Long
Required: Nothing
Thus var tree
has type FingerTree[?, Nothing]
instead of FingerTree[(Int, Long), Long]
Expectation
Should not infer Nothing
(no problem in Scala 2.13)