UNSAFE_METHOD_ACCESS warning should take into consideration existing "if" statements #8112
Blocker226
started this conversation in
Scripting
Replies: 2 comments 6 replies
-
It does, as far as I know, either this is a bug or a limitation with using custom classes Does it work if you do: if current_hover is Selectable:
current_hover.set_highlight(true) AFAIK CC @dalexeev |
Beta Was this translation helpful? Give feedback.
6 replies
-
see also #3691 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I am a junior developer with previous experience in Unity, transitioning to Godot and GDScript. I used to enjoy JetBrains Rider's C# support, which included auto-formatting for safe casting/method access.
Coming to GDScript, I noticed that when I set the
warnings/unsafe_method_access
setting in the project settings, it does encourage me to use theas
keyword to cast my derived classes accordingly, providing some level of validation on par with Rider.However, it does not take into account the presence of any type of checks that precede it, namely, cases like this, where the class
Selectable
extendsNode3D
:I'm hoping it's possible to add some sort of contextualisation to the editor for it to be able to identify such cases, and perhaps open up new opportunities to add auto-suggest/format/fix options down the line.
Beta Was this translation helpful? Give feedback.
All reactions