Editor code is not instantiable outside of the editor
(1d14c054a1/core/object/class_db.cpp (L369)).
This is fine for editor plugins and the like, but the GDScript analyzer
balks at it, causing F5 runs to fail: #73525.
Instead, we really just want to know if the type is abstract - so add
a new ClassDB method to check that and nothing else.
Update core/object/class_db.cpp
Apply code review comments
Co-Authored-By: Bryce <1522777+baptr@users.noreply.github.com>
This reverts commit dc73440f89.
This commit in some form is needed to fix handling of dependencies on
export, but as it's also used for import, it's exposing some pre-existing
issues which we need to solve first.
So reverting for now to give ourselves time to iron this out for a future
Godot release.
Fixes#91726.
Random-access access to `List` when iterating is `O(n^2)` (`O(n)` when
accessing a single element)
* Removed subscript operator, in favor of a more explicit `get`
* Added conversion from `Iterator` to `ConstIterator`
* Remade existing operations into other solutions when applicable
The parser and analyzer now track the dependencies of the script and
return the list when the resource loader ask for them.
What is considered a dependency:
- Any `preload()` call.
- The base script this one extends.
- Any identifier, including types, that refers to global scripts.
- Any autoload singleton reference.
The warning message mentions that local constants prefixed with `_` does
not generate the warning. This commit actually implements this warning
suppression.
If the type of a variable is a built-in Variant type, then it will
automatically be assigned a default value based on the type. This means
that the explicit initialization may be unnecessary. Thus this commit
removes the warning in such case.
This also changes the meaning of the unassigned warning to happen when
the variable is used before being assigned, not when it has zero
assignments.
If the left value type is known to be String, assume the format operator
(`%`) will return a string, since it works with any type in the right
hand side. This is also used by type inference even if the right hand
type is unknown at compile time.
Not defaulting to the native type rationale:
Defaulting to the native type is less than useful, as:
* There are very few native types that are extensible and have static methods.
* Defaulting to the native type does not account for a method being script-defined.
While the "real fix" would be to carefully track the source of the method, the get_function_signature method is already complicated enough.
This will at least ensure the resulting code should always be valid.
Not triggering on self-calls rationale:
Found in PR comment https://github.com/godotengine/godot/pull/85918#issuecomment-1935864459
```
static func example():
pass
func example2():
example() # self-call on static function
```
Disabling this warning on self-calls is:
* Consistent with other languages
* Important for anonymous classes (where the output code is unusable)