scala - Type aliasing to avoid name clash in type refinement -
can use aliasing don't need change either of type parameter/member in following name clash situation:
trait bar { type } trait foo { def get[a]: option[bar { type = }] // "illegal cyclic reference" }
i know can write
trait foo { def get[a1]: option[bar { type = a1 }] }
but prefer not change type name.
you e.g. this:
trait bar { type } trait foo { type m[x] = bar { type = x } def get[a]: option[m[a]] }
or inline:
def get[a]: option[({ type x[y] = bar { type = y }})#x[a]] = ???
or, if prefer:
def get[a]: option[({ type a1 = a; type x = bar { type = a1 }})#x] = ???
Comments
Post a Comment