rsc icon indicating copy to clipboard operation
rsc copied to clipboard

Simplify forSome types

Open wiwa opened this issue 6 years ago • 0 comments

Given:

class Box[A]
trait T
class A extends T
class B extends T
val foo = Seq(new Box[A], new Box[B])

Obtained:

val foo: Seq[Box[_1] forSome {  type _1 >: B with A <: T }] = Seq(new Box[A], new Box[B])

This will occur because Box is invariant.

Expected?:

val foo: Seq[Box[_ <: T]] = Seq(new Box[A], new Box[B])

i.e. we perhaps should expect something like _ <: LeastCommonAncestor. If that is AnyRef, maybe we should only ascribe Box[_].

wiwa avatar Aug 08 '19 15:08 wiwa