Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix #19789: Merge same TypeParamRef in orDominator #20090

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) }
Loading