# 可以强制存在量化类型变量只有一个类型吗？(Can an existentially quantified type variable be forced to have only a single type?)

``````trait Foo[T] {
def one: Foo[_ >: T]
def two: T
def three(x: T)
}

def test[T](f: Foo[T]) = {
val b = f.one
b.three(b.two)
}
``````

`````` found   : (some other)_\$1(in value b)
required: _\$1(in value b)
val x = b.three(b.two)
``````

``````trait Foo {
def two: X where ∃ X >: T
def three(x: X where ∃ X >: T)
}
``````

``````∃ X >: T such that trait Foo {
def two: X
def three(x: X)
}
``````

``````trait Foo[T] {
def one[X >: T]: Foo[X]
def two: T
def three(x: T)
}

def test[T, X >: T](f: Foo[T]) = {
val b = f.one[X]
b.three(b.two)
}
``````

`def one: Foo[_ >: T]`等价于

`def one: Foo[U >: T] forSome {type U >: T}`

`def one: Foo[U forSome {type U >: T}]`

``````b.two: _>:T
b.three(_>:T)
``````

``````A >: B >: C
def get:A
def put(B)
put(get) // type mismatch
``````

``````trait Foo[T] {
type U <: T
def one: Foo[U]
def two: T
def three(x: T)
}
``````

``````val x = new Foo[Dog]{
type U = Mammal
...
``````