-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
See references show unrelated results #56984
Comments
Summary: The "See References" feature in the Dart editor incorrectly shows unrelated results when searching for references to overridden methods in subclasses. For example, searching for references to |
If I'm understanding the example correctly, I think it is possible. Consider class D extends C implements B {} An instance of Because of the ability to implement almost any interface, it's very difficult to prove (in general) that it's impossible to ever invoke any override of an inherited method, so we don't try. In other words, this is working as intended, and I think we're unlikely to attempt to change it. |
I see your point. But this request does make sense for I've just tested the same code and it gives the same results. With either I would still like for it to scan the type hierarchy to try and find a match so that case is possible to show, but my feelings are not that strong and the code where I found this behaviour could easily be changed to final classes. Just to be clear, I would expect that result of EditThe thing that I understand of your example but I do find it weird is that if I have say: class E {
void m1() {}
} You could also say it could in the future have a subclass that extends/implements |
One more thing: Your example is flawed considering that both This would mean that (at least today) it is impossible to have a type that would match both, but the current "See references" would still show the same calls. |
Yes, certain combinations of
True, but a feature like this shouldn't try to reason about possible futures, only about the code that exists today. The point of the example is that we can't definitively know whether We could always find ways to improve the algorithm. Some of them might be performant and some wouldn't be. That then raises the question of whether we'd end up in an uncanny valley where the imprecision was worse than if we don't try to be so precise. |
That's more or less what your example and current implementation do here. They assume that I know the costs can be high for analysis but this can be really confusing. I opened this issue after a talk with DanTup on the extension Discord about the following image: I'm looking for the references for this |
I hadn't considered the point Brian made above when we first discussed this (a class using There have been requests to VS Code/LSP to allow these kinds of results to be grouped. I don't know if that would really help here (because I'm not sure what the groups would be), but maybe if it's ever implemented we could come up with a way to split/prioritise the results in a way that makes sense? 🤔 |
Even though I like the idea, I don't think it would make much sense. For the splitting to make any difference for this case we would need to have the full analysis anyway so until we decide that is needed/will be implemented, it won't make much sense I don't think. I'll leave this open for the request to consider |
In my screenshot I'll sepparate this repro into three files so the VSCode UI helps a bit to see the problem.
Here you can see that in the above structure
B
andC
are subclasses ofA
. In this example,m1
is called underA.m2
,B.m2
,C.m2
and underf1
.If you look for references of
A.m1
you get all calls to it in the list.Now the problem; if you ask for references for
B.m1
orC.m1
you get the same unrelated results:Here you can see that when asking for references of
C.m1
I get instance calls that would never beC
. InsideB
andf1
in this case.The same happens if you ask for references of
B.m1
, you get the call underC.m2
which could never be aB
instance.I'd like to ask for this to be worked on so that only
B
instances (or another subclass instance) would show. ForC.m1
for example, I was expecting only the call insideA.m2
andC.m2
. Definitelly not the call underf1
orB.m2
.The text was updated successfully, but these errors were encountered: