Inherit parent method return types for untyped overrides

This commit is contained in:
Leonard Pop 2026-02-02 17:05:40 +02:00
parent f4f0679a2d
commit 058a46f154
11 changed files with 93 additions and 9 deletions

View file

@ -24,9 +24,9 @@ class B extends A:
func untyped_to_node() -> Node: return null
func void_to_untyped(): pass
func variant_to_untyped(): pass
func int_to_untyped(): pass
func node_to_untyped(): pass
func variant_to_untyped(): return null
func int_to_untyped(): return 0
func node_to_untyped(): return null
func test():
pass

View file

@ -0,0 +1,25 @@
class A:
func return_float() -> float: return 1.0
func return_int_as_float(_x: int) -> float: return 1.0
func return_variant_as_float(_x: Variant) -> float: return 1.0
func return_float_array() -> Array[float]: return [1.0]
func return_float_dict() -> Dictionary[float, float]: return {1.0: 1.0}
class B extends A:
func return_float(): return 2
func return_int_as_float(x: int): return x
func return_variant_as_float(x: Variant): return x
func return_float_array(): return [2]
func return_float_dict(): return {2: 2}
func output(value: Variant) -> void:
print(var_to_str(value).replace("\n", ""))
func test():
var b := B.new()
output(b.return_float())
output(b.return_int_as_float(2))
output(b.return_variant_as_float(2))
output(b.return_float_array())
output(b.return_float_dict())

View file

@ -0,0 +1,6 @@
GDTEST_OK
2.0
2.0
2.0
Array[float]([2.0])
Dictionary[float, float]({2.0: 2.0})

View file

@ -1,6 +1,6 @@
class BaseClass:
func _get_property_list():
return {"property" : "definition"}
return [{"property" : "definition"}]
class SuperClassMethodsRecognized extends BaseClass:
func _init():
@ -11,7 +11,7 @@ class SuperMethodsRecognized extends BaseClass:
func _get_property_list():
# Recognizes super method.
var result = super()
result["new"] = "new"
result[0]["new"] = "new"
return result
func test():

View file

@ -1,3 +1,3 @@
GDTEST_OK
{ "property": "definition" }
{ "property": "definition", "new": "new" }
[{ "property": "definition" }]
[{ "property": "definition", "new": "new" }]

View file

@ -149,7 +149,7 @@ func test_unsafe_void_return() -> void:
@warning_ignore("native_method_override")
func get_class():
pass
return ""
# We don't want to execute it because of errors, just analyze.
func test():