Skip to content

Incorrect flags for some completion items #15790

Closed
@vzmerr

Description

@vzmerr

Compiler version

3.1.3

Minimized code

This code is from CompletionSnippetSuite in Metals which is run by the specified scala version.
@@ represents the cursor position.

object Main {
    new scala.Iterabl@@
}

Output

calling Completion.completions(pos) from Dotty API, produces

List(
  Completion(
    label = "Iterable",
    description = "=> collection.Iterable.type",
    symbols = List(method Iterable)
  ),
  Completion(
    label = "IterableOnce",
    description = "scala.IterableOnce",
    symbols = List(type IterableOnce)
  ),
  Completion(label = "Iterable", description = "scala.Iterable", symbols = List(type Iterable))
) 

Now the problem with the flags is that, for the last two items on the list, which are traits actually,

  • the symbol.is(Flags.Trait) returns false;
  • while symbol.info.typeSymbol.is(Flags.Trait) and symbol.info.typeSymbol.is(Trait) return true.

This is problematic for using the API for completions, such as when deciding whether to insert {} or when filtering results.

You might be interested in taking a look at these comments on the this PR for Scala 3 type completions in Metals.

Expectation

It is better if the flags are correctly set and are consistent.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions