Skip to content

Commit 0b4e677

Browse files
committed
Fix InferExpectedTypeSuite.unapply
1 parent da42229 commit 0b4e677

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: presentation-compiler/src/main/dotty/tools/pc/InferExpectedType.scala

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import dotty.tools.dotc.core.Types.*
1111
import dotty.tools.dotc.core.Types.Type
1212
import dotty.tools.dotc.interactive.Interactive
1313
import dotty.tools.dotc.interactive.InteractiveDriver
14+
import dotty.tools.dotc.typer.Applications.UnapplyArgs
15+
import dotty.tools.dotc.util.NoSourcePosition
1416
import dotty.tools.dotc.util.SourceFile
1517
import dotty.tools.dotc.util.Spans.Span
1618
import dotty.tools.pc.IndexedContext
@@ -89,6 +91,10 @@ object InterCompletionType:
8991
// val _: T = @@
9092
// def _: T = @@
9193
case (defn: ValOrDefDef) :: rest if !defn.tpt.tpe.isErroneous => Some(defn.tpt.tpe)
94+
case UnApply(fun, _, pats) :: _ =>
95+
val ind = pats.indexWhere(_.span.contains(span))
96+
if ind < 0 then None
97+
else Some(UnapplyArgs(fun.tpe.finalResultType, fun, pats, NoSourcePosition).argTypes(ind))
9298
// f(@@)
9399
case (app: Apply) :: rest =>
94100
val param =

Diff for: presentation-compiler/test/dotty/tools/pc/tests/InferExpectedTypeSuite.scala

-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class InferExpectedTypeSuite extends BasePCSuite:
193193
|""".stripMargin
194194
)
195195

196-
@Ignore("Unapply is not handled correctly.")
197196
@Test def unapply =
198197
check(
199198
"""|val _ =

0 commit comments

Comments
 (0)