Skip to content
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

Do not perform completion on higher kinded trees #13700

Merged
merged 3 commits into from Oct 7, 2021

Conversation

ghostbuster91
Copy link
Contributor

@ghostbuster91 ghostbuster91 commented Oct 5, 2021

This solution was developed during the 6th issue spree in the collaboration of @ghostbuster91 @KacperFKorban and @mtk.

We followed suggestion from @anatoliykmetyuk that invalid trees as ???.asInstanceOf[Seq] which would result in compilation error when submitted in repl shouldn't provide any completions.

Proposed solution behaves consistently both for ???.asInstanceOf[Seq] and ???.asInstanceOf[scala.collection.Seq] giving zero completions.

This closes #12465

Comment on lines 118 to 119
case Select(qual, _) :: _ if !qual.tpe.hasSimpleKind => Map.empty
case Select(qual, _) :: _ => completer.selectionCompletions(qual)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend swapping these 2 cases to avoid the unnecessary negation:

Suggested change
case Select(qual, _) :: _ if !qual.tpe.hasSimpleKind => Map.empty
case Select(qual, _) :: _ => completer.selectionCompletions(qual)
case Select(qual, _) :: _ if qual.tpe.hasSimpleKind => completer.selectionCompletions(qual)
case Select(qual, _) :: _ => Map.empty

@@ -169,3 +169,21 @@ class CustomCompletionTests extends DottyTest:

assert(offset == prefix.length)
assert(labels.contains("scala.Function2"))

@Test def i12465_hkt(): Unit =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these tests to CompletionTest.scala where they can be written in a much more concise way:

  @Test def i12465_hkt: Unit =
    code"""???.asInstanceOf[scala.collection.Seq].${m1}""".withSource
      .completion(m1, Set())

  @Test def i12465_hkt_alias: Unit =
    code"""???.asInstanceOf[Seq].${m1}""".withSource
      .completion(m1, Set())

@prolativ prolativ merged commit 28bd0da into scala:master Oct 7, 2021
@ghostbuster91 ghostbuster91 deleted the fix-12465 branch October 19, 2021 06:27
@Kordyjan Kordyjan added this to the 3.1.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL crashes at completion if type parameter is omitted
3 participants