Skip to content

Fix #6443: Widen typerefs to underlying lambdas in TypeTestCasts #6456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ object TypeTestsCasts {

def isClassDetermined(X: Type, P: AppliedType)(implicit ctx: Context) = {
val AppliedType(tycon, _) = P
val typeLambda = tycon.ensureLambdaSub.asInstanceOf[TypeLambda]

def underlyingLambda(tp: Type): TypeLambda = tp.ensureLambdaSub match {
case tp: TypeLambda => tp
case tp: TypeProxy => underlyingLambda(tp.superType)
}
val typeLambda = underlyingLambda(tycon)
val tvars = constrained(typeLambda, untpd.EmptyTree, alwaysAddTypeVars = true)._2.map(_.tpe)
val P1 = tycon.appliedTo(tvars)

Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i6443.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object Test {
trait Expr { type T }
type ExprExact[A] = Expr { type T = A }
type IndirectExprExact[A] = Expr { type S = A; type T = S }

def foo[A](e: ExprExact[A]): Unit = e match {
case _: IndirectExprExact[Int] =>
}
}