GDScript: Fix UNSAFE_CAST warning

This commit is contained in:
Danil Alexeev
2023-10-27 11:08:54 +03:00
parent 09946f79bd
commit 6e996a597f
22 changed files with 150 additions and 6 deletions

View File

@@ -0,0 +1,24 @@
func print_value(value: Variant) -> void:
if value is Object:
@warning_ignore("unsafe_method_access")
print("<%s>" % value.get_class())
else:
print(var_to_str(value))
func test():
var int_value := 1
print_value(int_value as Variant)
print_value(int_value as int)
print_value(int_value as float)
var node_value := Node.new()
print_value(node_value as Variant)
print_value(node_value as Object)
print_value(node_value as Node)
print_value(node_value as Node2D)
node_value.free()
var null_value = null
print_value(null_value as Variant)
@warning_ignore("unsafe_cast")
print_value(null_value as Node)

View File

@@ -0,0 +1,10 @@
GDTEST_OK
1
1
1.0
<Node>
<Node>
<Node>
null
null
null