Skip to content

Commit 4b711f5

Browse files
committed
Optimize comparing types in mergeRefinedOrApplied
1 parent ed9fecc commit 4b711f5

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
@@ -249,7 +249,8 @@ object TypeOps:
249249
mergeRefinedOrApplied(tp1, tp21) & mergeRefinedOrApplied(tp1, tp22)
250250
case _ =>
251251
fail
252-
tp1 match {
252+
if tp1 eq tp2 then tp1
253+
else tp1 match {
253254
case tp1 @ RefinedType(parent1, name1, rinfo1) =>
254255
tp2 match {
255256
case RefinedType(parent2, `name1`, rinfo2) =>
@@ -273,6 +274,7 @@ object TypeOps:
273274
}
274275
case AndType(tp11, tp12) =>
275276
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
277+
case tp1: TypeParamRef if tp1 == tp2 => tp1
276278
case _ => fail
277279
}
278280
}

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)