scala/scala — pull request #3759 by retronym (2014-05-17 21:08:51+00:00)
Title: SI-8599 Improve type variable inference in nested matches

Refine the upper and lower bounds independentally, rather than
bailing out if `!(lo1 <:< hi1)`.

Before, the enclosed test case traced out as follows:

```
inferTypedPattern
-----------------------------------
pattpt = RefinementTest.Child[c]
pt = RefinementTest.Parent[a]
ptparams = [type a]
ptvars = [=?(?c, ?c)]
ptvars foreach instantiateTypeVar

instantiateTypeVar
-----------------------------------
tvar = =?(?c, ?c)
tb0 = >: A <: A
instBounds(tvar)

instBounds
-----------------------------------
loBounds = [(c, c)]
hiBounds = [(c, c)]
tparam = type a
val TypeBounds(lo, hi) = tparam.info.bounds
lo = A
hi = A
lub(A :: (c, c) :: Nil) = Any
glb(A :: (c, c) :: Nil) = A with (c, c)
result = >: Any <: A with (c, c)

lo1 = Any
hi1 = A with (c, c)
if (! (lo1 <:< hi1) )
log(s"inconsistent bounds: discarding TypeBounds($lo1, $hi1)")
```

So because we haven't yet refined the info of `a`, it still appears
distinct from `(c, c)`, and the LUB is `Any`. Based on this, we
don't proceed to refine the type.

This commit changes the process to individually retain or discard
the low and high bounds, which is enough to tie the knot here.