content

While enabling all of the compiler errors, I ran into this problem with autoloads:

[!quote] AdriaandeJongh
After making a singleton autoload as described here but instead of adding the script directly you autoload a packed scene with a single node with the script attached, the editor will give a UNSAFE_METHOD_ACCESS warning (when enabled) when a method to that singleton is used.

The only workaround here is to add a class_name to the singleton script and name the autoload different from the script so it can be cast:

SceneManagerInstance.load_scene("level_test") # gives warning
(SceneManagerInstance as SceneManager).load_scene("level_test") # ugly workaround

Expected behavior here is that the singleton is type hinted by the autoload system.

meta

created:

backlinks: Singleton autoloads have an unknown type no signal logs

commit: 74cb7704