File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1098,10 +1098,18 @@ object Types {
10981098 * def o: Outer
10991099 * <o.x.type>.widen = o.C
11001100 */
1101- final def widen (using Context ): Type = widenSingleton match {
1101+ final def widen (using Context ): Type = this match
1102+ case _ : TypeRef | _ : MethodOrPoly => this // fast path for most frequent cases
1103+ case tp : TermRef => // fast path for next most frequent case
1104+ if tp.isOverloaded then tp else tp.underlying.widen
1105+ case tp : SingletonType => tp.underlying.widen
11021106 case tp : ExprType => tp.resultType.widen
1103- case tp => tp
1104- }
1107+ case tp =>
1108+ val tp1 = tp.stripTypeVar.stripAnnots
1109+ if tp1 eq tp then tp
1110+ else
1111+ val tp2 = tp1.widen
1112+ if tp2 ne tp1 then tp2 else tp
11051113
11061114 /** Widen from singleton type to its underlying non-singleton
11071115 * base type by applying one or more `underlying` dereferences.
You can’t perform that action at this time.
0 commit comments