scalacenter/scala

Support type member refinements

bishabosha opened this issue · 1 comments

[2 days]

trait Foo {
  type T
  type U
  def foo: (T, U)
}

trait FooT {
  type T
  def fooT: T
}

trait FooU {
  type U
  def fooU: U
}

class Bar[A, B] {
  def bar[F <: Foo { type T = A; type U = B }](member: F): (member.T, member.U) = {
    member.foo
  }
}

class Baz[A, B, F <: Foo { type T = A; type U = B }] {
  def baz(member: F): (member.T, member.U) = {
    member.foo
  }
}

class Qux[A, B, F <: FooT with FooU { type T = A; type U = B }] {
  def qux(member: F): (member.T, member.U) = {
    (member.fooT, member.fooU)
  }
}

class Zot[A, B] {
  def zot[F <: FooT with FooU { type T = A; type U = B } ](member: F): (member.T, member.U) = {
    (member.fooT, member.fooU)
  }
}

i.e. support multiple refinements of type members in both type and type-tree position

closed by #56