Skip to content

Commit 5bd4644

Browse files
authored
Merge pull request scala#411 from scala/backport-lts-3.3-23045
Backport "Compare TypeVar and TypeParamRef in mergeRefinedOrApplied" to 3.3 LTS
2 parents 6f4a98f + c880735 commit 5bd4644

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,15 @@ object TypeOps:
284284
}
285285
case AndType(tp11, tp12) =>
286286
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
287-
case tp1: TypeParamRef if tp1 == tp2 => tp1
287+
case tp1: TypeParamRef =>
288+
tp2.stripTypeVar match
289+
case tp2: TypeParamRef if tp1 == tp2 => tp1
290+
case _ => fail
291+
case tp1: TypeVar =>
292+
tp2 match
293+
case tp2: TypeVar if tp1 == tp2 => tp1
294+
case tp2: TypeParamRef if tp1.stripTypeVar == tp2 => tp2
295+
case _ => fail
288296
case _ => fail
289297
}
290298
}

tests/pos/i23032.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def f[F[_], T, U]: F[T] | F[U] = ???
2+
def x = f.toString

0 commit comments

Comments
 (0)