Why do I get an narrowing conversion warning when type hinting for Physics2DDirectSpaceState?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Timeearl

Hi! I’m having trouble using a function i made which throws a warning whenever I use type hinting on a Physics2DDirectSpaceState

The exact warning is:

Narrowing conversion (float is converted to int and loses precision).

And occurs in the following code block on the return statement.

func _send_ray(space_state: Physics2DDirectSpaceState,
               offset: Vector2) -> Dictionary:
    return space_state.intersect_ray(
        global_position,
        visual_entered_body.global_position + offset,
        [self],
        currentMask)

where all i’m doing is a ray cast.
the warning doesn’t occur when not using type hinting for space_state:

func _send_ray(space_state, offset: Vector2) -> Dictionary:

doesn’t lead to a warning

initializing space_state using type hinting doesn’t make a difference here.

var space_state: Physics2DDirectSpaceState  = get_world_2d().direct_space_state
result: Dictionary = _send_ray(space_state, Vector2.ZERO)

and

var space_state = get_world_2d().direct_space_state
result: Dictionary = _send_ray(space_state, Vector2.ZERO)

lead to the same result.

I’m not quite shure if the narrowing conversion is actually happening and what is affected by it.
If you have any Idea on how to avoid it other than not using type hinting please leave an answer.