scala/scala — pull request #2157 by retronym (2013-02-22 22:11:24+00:00)
Title: SI-7171 Consider prefix when assessing type finality.

`Type#isFinalType` determines if a type could have a
non-bottom subtype. This property is exploited by
the pattern matcher to flag impossible patterns.

This check was ignoring the type's prefix, and
incorrectly deemed that `T#A` in `trait T { final class A }`
was a final type. But it could have been subtyped by
`U#A` where `U` <:< `T`, or, more simply, by `T.this.A`.

Now, type finality requires that the prefix is stable.

The existing test cases inneg/patmat-type-check.scala
still correctly flag incompatiblities.

`isFinalType` is also used by some code that massages
pattern matches post specialization. That is actually
either broken or obsolete under virtpatmat, I've opened
SI-7172 to invesigate that.

It's also used by GenICode to determine whether to emit
the appropriate equality checks that are correct in the
face of boxing. It is possible that this change will force
the slow path in some rare cases, but it won't affect
correctness.

Review by @adriaanm and @JamesIry