Can an existentially quantified type variable be forced to have only a single type?

前端 未结 2 1852
南方客
南方客 2021-01-13 11:54

Consider the following code

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         


        
2条回答
  •  粉色の甜心
    2021-01-13 12:56

    def one: Foo[_ >: T] is equivalent to

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

    this one instead works

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

    I do not however understand why this would make a difference. It seems like it should not to me. (shrug)

提交回复
热议问题