Skip to content

Unapply completions should be completed in nested unapply context #19972

Closed
@rochala

Description

@rochala

Compiler version

3.4.1

Minimized code

This test should be changed and pass.

  // file dotty/tools/pc/tests/completion/CompletionSuite.scala
  @Test def pat1 =
    check(
      s"""|object Main {
          |  Option(1) match {
          |    case List(Som@@)
          |}
          |""".stripMargin,
      """|Some(value) scala
         |Some scala
         |""".stripMargin
    )

Output

      """|Some scala
         |Some[A](value: A): Some[A]
         |""".stripMargin

Expectation

Extra unapply completion should be added to the completion list, where it is allowed and completion with expected type parameters should be filtered as it is illegal at this position.
The test should pass.

Tips

My guess is that the root of the issue is in CaseDefCompletions, which is responsible for providing us with extra results. The logic probably matches against specific patterns, but what we should do instead is to recursively try to find whether one of the owners is case definition and all other owners in between are unapply methods.

Metadata

Metadata

Assignees

Labels

area:presentation-compilerRelated to the presentation compiler module used by Metals and possibly other toolsitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions