Equality of paths

I’m studying the concept of path as implemented in the compiler. Since it seems that a path can be viewed as a type and a term I think the relevant files are Trees.scala and Types.scala. In Types.scala I find the following encoding:

p.x.type -> TermRef(p,x)
p#T -> TypeRef(p,T)
p.x.T = p.x.type#T is a derived form

I’m wondering if there is a procedure determining if two types are equals (in particular two path dependent types are equal) and how should I find it. On the other hand, I’m interested in why this notation. Could I just not have written:

p.type
p#T?

Update

Method “matches” at line 980 of Types.scala

def matches(that: Type)(implicit ctx: Context): Boolean = {
record(“matches”)
ctx.typeComparer.matchesType(this, that, relaxed = !ctx.phase.erasedTypes)
}

seems to do the job of comparing types for equality

Hi Rodrigo,

Generally, we only have two equalities in the type checker:

  • simple structural equality ==
  • mutual subtyping: A =:= B if A <:< B and B <:< A.

I believe it’s the second equality that you want. matches is a somewhat looser =:= that is used to determine whether a method can override another one.