aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala5
-rw-r--r--tests/pos/dependent-extractors.scala14
2 files changed, 16 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 37a9f0ba0..d70546f9d 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -736,8 +736,7 @@ trait Applications extends Compatibility { self: Typer =>
}
unapplyFn.tpe.widen match {
- case mt: MethodType if mt.paramTypes.length == 1 && !mt.isDependent =>
- val m = mt
+ case mt: MethodType if mt.paramTypes.length == 1 =>
val unapplyArgType = mt.paramTypes.head
unapp.println(i"unapp arg tpe = $unapplyArgType, pt = $selType")
def wpt = widenForMatchSelector(selType) // needed?
@@ -778,7 +777,7 @@ trait Applications extends Compatibility { self: Typer =>
tree.pos)
}
- val dummyArg = dummyTreeOfType(unapplyArgType)
+ val dummyArg = dummyTreeOfType(ownType)
val unapplyApp = typedExpr(untpd.TypedSplice(Apply(unapplyFn, dummyArg :: Nil)))
val unapplyImplicits = unapplyApp match {
case Apply(Apply(unapply, `dummyArg` :: Nil), args2) => assert(args2.nonEmpty); args2
diff --git a/tests/pos/dependent-extractors.scala b/tests/pos/dependent-extractors.scala
new file mode 100644
index 000000000..4d0830155
--- /dev/null
+++ b/tests/pos/dependent-extractors.scala
@@ -0,0 +1,14 @@
+object Test {
+
+ abstract class C { type T; val x: T }
+
+ val c = new C { type T = Int; val x = 1 }
+
+ object X { def unapply(x: C): Some[x.T] = Some(x.x) }
+
+ val y = c match { case X(y) => y }
+ val y1: Int = y
+
+ val z = (c: Any) match { case X(y) => y }
+ val z1: C#T = z
+}