Based on the answers to this question, it appears that placing "forSome" after a component of the type definition is different from placing it at the end of the whole thing. For instance, it seems there is a difference between the following:
def one: Foo[U >: T] forSome {type U >: T}
def one: Foo[U forSome {type U >: T}]
The Scala language specification does not seem to say anything about the difference, and I would have imagined that moving the quantifiers to the outside would make no difference. If it did make a difference, I would have thought it would be as described in this answer, which basically says Set[X forSome {type X}] allows X to vary between set elements, where Set[X] forSome {type X} does not. However, this does not seem to be the whole story and/or is not correct, because this does not compile:
trait Bar {
def test: Set[X] forSome {type X}
}
def test(b: Bar) {
val set = b.test
val h = set.head
set.contains(h)
}
But this does:
trait Bar {
def test: Set[X forSome {type X}]
}
def test(b: Bar) {
val set = b.test
val h = set.head
set.contains(h)
}
It seems as if Set[X] forSome {type X} creates a separate abstract type for every usage site in the instantiated class, where Set[X forSome {type X}] creates only one and uses it for the entire class. This is the opposite of what I would have expected and seems inconsistent with the answer reference above.