In Scala 2.10, this works:
implicit class T1[A](val self: Iterator[A]) {
def :+[B >: A](elem: B): Iterator[B] =
self ++ Iterator(elem)
}
But when I try to make it a value class:
implicit class T2[A](val self: Iterator[A]) extends AnyVal {
def :+[B >: A](elem: B): Iterator[B] =
self ++ Iterator(elem)
}
I get the error:
type arguments [B] do not conform to method ++'s type parameter bounds [B >: A]
Why?
It is a bug and it is already fixed in the current nightly.
See this ticket for more information.