@@ -3,17 +3,17 @@ package dotty.tools.dotc.qualified_types
33import scala .util .hashing .MurmurHash3 as hashing
44
55import dotty .tools .dotc .ast .tpd .{closureDef , Apply , Block , DefDef , Ident , Literal , New , Select , Tree , TreeOps , TypeApply , Typed , TypeTree }
6- import dotty .tools .dotc .core .Contexts .Context
6+ import dotty .tools .dotc .core .Contexts .{ ctx , Context }
77import dotty .tools .dotc .core .Decorators .i
88import dotty .tools .dotc .core .Symbols .Symbol
9- import dotty .tools .dotc .core .Types .{MethodType , TermRef , Type , TypeVar }
9+ import dotty .tools .dotc .core .Types .{MethodType , NamedType , TermRef , Type , TypeVar }
1010import dotty .tools .dotc .core .Symbols .defn
1111
1212import dotty .tools .dotc .reporting .trace
1313import dotty .tools .dotc .config .Printers
1414
1515private abstract class QualifierComparer :
16- private def typeIso (tp1 : Type , tp2 : Type ) =
16+ protected def typeIso (tp1 : Type , tp2 : Type ) =
1717 val tp1stripped = stripPermanentTypeVar(tp1)
1818 val tp2stripped = stripPermanentTypeVar(tp2)
1919 tp1stripped.equals(tp2stripped)
@@ -91,6 +91,16 @@ private[qualified_types] object QualifierStructuralComparer extends QualifierCom
9191 override def hashCode : Int = hash(tree)
9292
9393private [qualified_types] final class QualifierAlphaComparer (using Context ) extends QualifierComparer :
94+ override protected def typeIso (tp1 : Type , tp2 : Type ): Boolean =
95+ def normalizeType (tp : Type ): Type =
96+ tp match
97+ case tp : TypeVar if tp.isPermanentlyInstantiated => tp.permanentInst
98+ case tp : NamedType =>
99+ if tp.symbol.isStatic then tp.symbol.termRef
100+ else normalizeType(tp.prefix).select(tp.symbol)
101+ case tp => tp
102+ super .typeIso(normalizeType(tp1), normalizeType(tp2))
103+
94104 override def iso (tree1 : Tree , tree2 : Tree ): Boolean =
95105 trace(i " iso $tree1 ; $tree2" ):
96106 (tree1, tree2) match
0 commit comments