You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.<refinement#1>.type
tp2 = Use.<refinement#2>.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`.
found : AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>) <: AnyRef{def x: Int}; type Memory = this.Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)}
14
+
required: AnyRef{type Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>) <: AnyRef{def x: Int @ann}; type Memory = this.Mem(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)(in <refinement of AnyRef>)}
0 commit comments