Skip to content

Commit 78d2c9a

Browse files
committed
Simplify widenToParents
No need to form the glb.
1 parent de870e2 commit 78d2c9a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ class TypeApplications(val self: Type) extends AnyVal {
295295
* no type field named `p` in this type, or `p` is a named type parameter of this type.
296296
* The first case is important for the recursive case of AndTypes, because some of their operands might
297297
* be missing the named parameter altogether, but the AndType as a whole can still
298-
* contain it.
298+
* contain it.
299299
*/
300300
final def widenToNamedTypeParams(params: Set[TypeSymbol])(implicit ctx: Context): Type = {
301301

@@ -311,10 +311,11 @@ class TypeApplications(val self: Type) extends AnyVal {
311311

312312
/** Widen type by forming the intersection of its widened parents */
313313
def widenToParents(tp: Type) = {
314-
val parents = tp.parents.map(p => tp.baseTypeWithArgs(p.symbol))
315-
ctx.typeComparer.glb(parents.map(_.widenToNamedTypeParams(params)))
314+
val parents = tp.parents.map(p =>
315+
tp.baseTypeWithArgs(p.symbol).widenToNamedTypeParams(params))
316+
parents.reduceLeft(ctx.typeComparer.andType(_, _))
316317
}
317-
318+
318319
if (isOK(self)) self
319320
else self match {
320321
case self @ AppliedType(tycon, args) if !isOK(tycon) =>

0 commit comments

Comments
 (0)