-
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
Go-to-Definition on super() constructor call goes to class when there's no default constructor #55241
Comments
I almost always have an opinion. :-) I think it's a bit of a wrinkle, but,
The worst part, IMO, is that once the user navigates to The real question is, which would best fit the user's expectations? I have two data points (yours and mine), but it's hard to generalize from there. |
From a pedantic point of view, going to And as mentioned, if Now, let's make things interesting. class A {
A();
}
mixin M {}
class C extends A with M {
C() : super();
} Now, which constructor does Nobody wants to go there. Ever. (If there even is a "there" to go. I don't know where I'd put the cursor. On the The denoted super-constructor existing is not enough reason to navigate to it. If I instead write the same program, just with the mixin application being named instead of anonymous: class A {
A();
}
mixin M {}
abstract class AM = A with M;
class C extends AM {
C() : super();
} then what? Going to I'd do the same thing here as for I am leaning towards the current, pedantically correct, behavior. (I don't think it's possible to display a synthetic default constructor, like |
TIL you can do this 🤯
We could potentially do this (it's basically a variation of "Closing Labels"), although I'd really like to move closing labels to something more standard like Inlay Hints - but currently we can't control the styling for that (requires microsoft/vscode#151920). I am less sure now that this should be changed. I do feel like not being able to continue the chain sucks, but you can always invoke Go to Super to get to the super class and then manually locate the constructor from there. It's not perfect, but it seems like there probably isn't any perfect solution here (besides maybe showing synthetic constructors in the editor, but I'm also not convinced that wouldn't be a little weird and cause things to jump around as you're adding constructors). I'll close this on the assumption we probably don't want to change this then (we can always re-open if additional opinions change things, or if we think we should try implementing some other mechanism like showing the synthetic constructor, or a way to jump to super constructor from a class that doesn't have an explicit constructor). |
In this code, I think I would expect Go-to-Definition on the
super()
constructor call in theC()
constructor to jump to theA()
constructor.However, it currently jumps to
class ^B
.@bwilkerson any opinion on this? Technically the implied constructor in
B
is what's being called, but since it's synthetic I feel like we should skip it.However, I'm not sure there aren't edge cases that might make this seem inconsistent (for example if
B
didn't haveA
as a subclass, then probably we would need to jump toclass ^B
).The text was updated successfully, but these errors were encountered: