Skip to content

Commit 9b060ec

Browse files
committed
Handle comparing with TypeVar in mergeRefinedOrApplied
Closes #23032
1 parent 05b102a commit 9b060ec

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
@@ -278,7 +278,15 @@ object TypeOps:
278278
}
279279
case AndType(tp11, tp12) =>
280280
mergeRefinedOrApplied(tp11, tp2) & mergeRefinedOrApplied(tp12, tp2)
281-
case tp1: TypeParamRef if tp1 == tp2 => tp1
281+
case tp1: TypeParamRef =>
282+
tp2.stripTypeVar match
283+
case tp2: TypeParamRef if tp1 == tp2 => tp1
284+
case _ => fail
285+
case tp1: TypeVar =>
286+
tp2 match
287+
case tp2: TypeVar if tp1 == tp2 => tp1
288+
case tp2: TypeParamRef if tp1.stripTypeVar == tp2 => tp2
289+
case _ => fail
282290
case _ => fail
283291
}
284292
}

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)