You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An UNSAFE_METHOD_ACCESS warning is emitted when I would've expected the type system to automatically type-narrow inside of a type guard, something like:
if node is SomeType:
# `node` should be a `SomeType` in this block.
node.some_type_method()
Steps to reproduce
Enable 'UNSAFE_METHOD_ACCESS' warnings in project settings
Add this function anywhere and play the game:
func test(node: Node2D) -> void:
if node is Area2D:
node.get_overlapping_areas()
The following warning is emitted:
W 0:00:00:0707 The method "get_overlapping_areas()" is not present on the inferred type "Node2D" (but may be present on a subtype).
This can be worked around by explicitly type casting after performing the check:
func test(node: Node2D) -> void:
if node is Area2D:
(node as Area2D).get_overlapping_areas()
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered:
Tested versions
4.2.1.stable.official
System information
Godot v4.2.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (NVIDIA; 31.0.15.2849) - 13th Gen Intel(R) Core(TM) i9-13900K (32 Threads)
Issue description
An UNSAFE_METHOD_ACCESS warning is emitted when I would've expected the type system to automatically type-narrow inside of a type guard, something like:
Steps to reproduce
This can be worked around by explicitly type casting after performing the check:
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: