-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Incorrect flags for some completion items #15790
Comments
I think that the behavior is correct. Seems like those items are type aliases. see here |
Thank you for the reply; but why are the values of Also, it is unsuspected that Any chance the api can change to become a little bit user-friendlier? Almost everyone on our team got a little bit confused about the expected values of the flags in this case. Basically we want to detect abstract types for the purpose of deciding where the completion should be allowed or for inserting Which flag combination do you recommend? We need to test them for various use-cases to make sure that they behave the expected way and valid results do not get incorrectly filtered out. |
Another inconsistency case: In this code, from metals completion test cases,
we have:
is this expected? Why is that? How can we predict the flag values? |
I think @KacperFKorban is right. The flags of a symbol depend on how something is defined syntactically, not on the actual semantics and this is expected, e.g. in trait Foo the symbol type Bar = Foo
trait Bar = Foo (which is not syntactically correct scala code). val x = 2 the type of symbol val x: Int = 2 |
@prolativ thank you for the elaboration. But still, this does not explain the inconsistencies. |
@prolativ I think it would be more helpful to the consumers of the api, to set the flag values according to the semantics though. We definitely need that for completions in Metals. |
In your second example |
So the values on the |
So generally, if the method flag is set, the type symbol flags show the category of the return type, right? |
Not really. trait Foo[A] // sym1
object Foo // sym2
def foo = new Foo[Int] {} // sym3
type Bar[A] = Foo[A] // sym4
val Bar = Foo // sym5
def bar = new Bar[Int] {} // sym6 This snippet declares 6 symbols. In your particular case you should however note that |
@prolativ awesome elaboration. Thank you so much 😊 |
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.Output
calling
Completion.completions(pos)
from Dotty API, producesNow the problem with the flags is that, for the last two items on the list, which are
trait
s actually,symbol.is(Flags.Trait)
returnsfalse
;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.
The text was updated successfully, but these errors were encountered: