Skip to content

Commit

Permalink
Fix #19789: Merge same TypeParamRef in orDominator (#20090)
Browse files Browse the repository at this point in the history
Fix #19789

Merge refined or applied types if they share the same `TypeParamRef` as
tycon in `orDominator`.
  • Loading branch information
odersky authored Apr 10, 2024
2 parents ed9fecc + 4b711f5 commit 9b3495a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ object TypeOps:
mergeRefinedOrApplied(tp1, tp21) & mergeRefinedOrApplied(tp1, tp22)
case _ =>
fail
tp1 match {
if tp1 eq tp2 then tp1
else tp1 match {
case tp1 @ RefinedType(parent1, name1, rinfo1) =>
tp2 match {
case RefinedType(parent2, `name1`, rinfo2) =>
Expand All @@ -273,6 +274,7 @@ object TypeOps:
}
case AndType(tp11, tp12) =>
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
case tp1: TypeParamRef if tp1 == tp2 => tp1
case _ => fail
}
}
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/i19789.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Kinded[F[_]] = F[Any] | F[Nothing]

def values[F[_]]: Vector[Kinded[F]] = ???

def mapValues[F[_], T](f: Kinded[F] => T): Vector[T] = values[F].map { case x => f(x) }

0 comments on commit 9b3495a

Please sign in to comment.