Incorrect flags for some completion items
See original GitHub issueCompiler 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 trait
s actually,
- the
symbol.is(Flags.Trait)
returnsfalse
; - while
symbol.info.typeSymbol.is(Flags.Trait)
andsymbol.info.typeSymbol.is(Trait)
returntrue
.
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.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Outlook "clear flag" changes message to "mark
The main problem with the way Outlook is doing it now (converting a clear flag to mark completed) is that the messages with...
Read more >Registration - Vehicle Flags - Pages - Maryland MVA
The presence of a flag on your vehicle's record will prevent you from completing certain types of MVA transactions such as renewing your...
Read more >Deletion Flag setting Error message for production order
Hi Aparna,. This is absolutely fine to set the deletion flag to archieve the Production Orders. For this error, which you are getting,...
Read more >Common Red Flags - Fannie Mae
However, several red flags in a file may ... Verifications completed on the same day they were ordered. ▫ Verifications completed on weekend...
Read more >How to Remove Negative Items From Your Credit Report
Read on to learn how to remove erroneous information from your credit report — and some tips on how to handle those negative...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not really.
typeSymbol
also returns a symbol Let’s consider a simple scenario:This snippet declares 6 symbols. Here only
sym1
is a trait symbol sosym1.is(Trait)
should be true.sym4
is declared astype
sosym4.is(Trait)
is false. However as typeBar
proxies toFoo
I believesym4.info.typeSymbol
should returnsym1
(and so shouldsym1.info.typeSymbol
) so if you want to check if a type symbolsym
is semantically a trait I think something likesym.info.typeSymbol.is(Trait)
should do the work (although I haven’t tested it).sym3
is a term symbol representing a method andsym3.info
is the typeFoo[Int]
so its type symbolsym3.info.typeSymbol
is alsosym1
.In your particular case you should however note that
new Fo@@
should not always directly completeFoo[]
as if some type was declared inside ofFoo
’s companion object the user might rather prefer to complete justnew Foo
so that the user continues typing likenew Foo.Quux
In your second example
scala.concurrent.ExecutionContext.Implicits.global
is defined asdef
so it’s a method symbol (not a trait) but it has typescala.concurrent.ExecutionContext
, andExecutionContext
is defined as a trait so its symbol is a trait. So the results you get are correct