Skip to content

Commit c880735

Browse files
DolphinChipstgodzik
authored andcommitted
Handle comparing with TypeVar in mergeRefinedOrApplied
Closes scala#23032 [Cherry-picked 9b060ec]
1 parent fcfe738 commit c880735

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

+9-1
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

+2
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)