Skip to content

Commit d68559a

Browse files
committed
avoid stripping type variables in OrderingConstraint.replace
1 parent 9b1b87e commit d68559a

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
445445
* of the parameter elsewhere in the constraint by type `tp`.
446446
*/
447447
def replace(param: TypeParamRef, tp: Type)(using Context): OrderingConstraint =
448-
val replacement = tp.dealiasKeepAnnots.stripTypeVar
448+
val replacement = tp.dealiasKeepAnnots
449449
if param == replacement then this.checkNonCyclic()
450450
else
451451
assert(replacement.isValueTypeOrLambda)

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ object Inferencing {
436436
}
437437

438438
// We add the created symbols to GADT constraint here.
439-
if (res.nonEmpty) ctx.gadt.addToConstraint(res)
439+
if res.nonEmpty then ctx.gadt.addToConstraint(res)
440+
440441
res
441442
}
442443

tests/neg/pdgadt-wildcard.scala

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/pos/pdgadt-wildcard.scala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
trait Expr { type T }
2+
case class Inv[X](x: X) extends Expr { type T = X }
3+
case class Inv2[X](x: X) extends Expr { type T >: X }
4+
5+
def eval(e: Expr): e.T = e match
6+
case Inv(x) => x
7+
case Inv2(x) => x
8+
9+
trait Foo[-T]
10+
case class Bar() extends Foo[Int]
11+
12+
def foo(e1: Expr, e2: Foo[e1.T]) = e1 match {
13+
case Inv2(x) => e2 match {
14+
case Bar() =>
15+
val t0: Int = x
16+
val t1: e1.T = x
17+
val t2: Int = t1
18+
}
19+
}
20+

0 commit comments

Comments
 (0)