Skip to content

Commit d38048a

Browse files
committed
Fix #6443: Widen typerefs to underlying lambdas in TypeTestCasts
1 parent d78b8c0 commit d38048a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ object TypeTestsCasts {
9292

9393
def isClassDetermined(X: Type, P: AppliedType)(implicit ctx: Context) = {
9494
val AppliedType(tycon, _) = P
95-
val typeLambda = tycon.ensureLambdaSub.asInstanceOf[TypeLambda]
95+
96+
def underlyingLambda(tp: Type): TypeLambda = tp.ensureLambdaSub match {
97+
case tp: TypeLambda => tp
98+
case tp: TypeProxy => underlyingLambda(tp.superType)
99+
}
100+
val typeLambda = underlyingLambda(tycon)
96101
val tvars = constrained(typeLambda, untpd.EmptyTree, alwaysAddTypeVars = true)._2.map(_.tpe)
97102
val P1 = tycon.appliedTo(tvars)
98103

tests/pos/i6443.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test {
2+
trait Expr { type T }
3+
type ExprExact[A] = Expr { type T = A }
4+
type IndirectExprExact[A] = Expr { type S = A; type T = S }
5+
6+
def foo[A](e: ExprExact[A]): Unit = e match {
7+
case _: IndirectExprExact[Int] =>
8+
}
9+
}

0 commit comments

Comments
 (0)