scala/scala — pull request #3267 by retronym (2013-12-11 23:57:36+00:00)
Title: SI-8071 Allow unification for prefixes of form ThisType(refinement)

In the enclosed test, we ended up relating the following types:

tp1 = AnyRef{type Mem <: AnyRef{def x: Int}; type Memory#3 = this.Mem}" // #1
tp2 = AnyRef{type Mem <: AnyRef{def x: Int @ann}; type Memory#4 = this.Mem}" // #2

The first was the result of `Use.field`, in which the `asSeenFrom`
had stripped the annotation. (`AsSeenFromMap` extends
`KeepOnlyTypeConstraints`).

The second type was the declared return type of the accessor method.

Usually, `=:=` and `<:<` are annotation agnostic, and unless a plugin
says otherwise, just compare the underlying types.

But, when refinements are thrown into the mix, one has to wade
through `specializesSym`.

On the way, we get to:

tp1 = Use..type
tp2 = Use..type
sym1 = type Memory#3
sym2 = type Memory#4
tp2.memberType(sym2).substThis(tp2.typeSymbol, tp1) =:= tp1.memberType(sym1)

And finally down to business in `equalSymsAndPrefixes`.

Here, we allow loose matching, based on symbol names, if the prefixes
are =:= and represent a refined type (or a singleton type or type
variable over a refined type.) But none of these cases covered what
we encounter here: a this type over a refinement class.

This commit adds that case to `isEligibleForPrefixUnification`.

Review by @adriaanm