Skip to content

Commit 6beee6a

Browse files
Backport "Fix #19789: Merge same TypeParamRef in orDominator" to LTS (#21056)
Backports #20090 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 57841fd + a3004fa commit 6beee6a

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ object TypeOps:
255255
mergeRefinedOrApplied(tp1, tp21) & mergeRefinedOrApplied(tp1, tp22)
256256
case _ =>
257257
fail
258-
tp1 match {
258+
if tp1 eq tp2 then tp1
259+
else tp1 match {
259260
case tp1 @ RefinedType(parent1, name1, rinfo1) =>
260261
tp2 match {
261262
case RefinedType(parent2, `name1`, rinfo2) =>
@@ -279,6 +280,7 @@ object TypeOps:
279280
}
280281
case AndType(tp11, tp12) =>
281282
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
283+
case tp1: TypeParamRef if tp1 == tp2 => tp1
282284
case _ => fail
283285
}
284286
}

tests/pos/i19789.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type Kinded[F[_]] = F[Any] | F[Nothing]
2+
3+
def values[F[_]]: Vector[Kinded[F]] = ???
4+
5+
def mapValues[F[_], T](f: Kinded[F] => T): Vector[T] = values[F].map { case x => f(x) }

0 commit comments

Comments
 (0)