Skip to content

Backport "Compare TypeVar and TypeParamRef in mergeRefinedOrApplied" to 3.3 LTS #411

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2025
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
10 changes: 9 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,15 @@ object TypeOps:
}
case AndType(tp11, tp12) =>
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
case tp1: TypeParamRef if tp1 == tp2 => tp1
case tp1: TypeParamRef =>
tp2.stripTypeVar match
case tp2: TypeParamRef if tp1 == tp2 => tp1
case _ => fail
case tp1: TypeVar =>
tp2 match
case tp2: TypeVar if tp1 == tp2 => tp1
case tp2: TypeParamRef if tp1.stripTypeVar == tp2 => tp2
case _ => fail
case _ => fail
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/pos/i23032.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def f[F[_], T, U]: F[T] | F[U] = ???
def x = f.toString