mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 11:32:13 +00:00
[GDScript] Fix get_method
for lambda self Callable
s
This commit is contained in:
parent
ec02d406ca
commit
f68ab70a6a
@ -198,6 +198,10 @@ ObjectID GDScriptLambdaSelfCallable::get_object() const {
|
||||
return object->get_instance_id();
|
||||
}
|
||||
|
||||
StringName GDScriptLambdaSelfCallable::get_method() const {
|
||||
return function->get_name();
|
||||
}
|
||||
|
||||
int GDScriptLambdaSelfCallable::get_argument_count(bool &r_is_valid) const {
|
||||
if (function == nullptr) {
|
||||
r_is_valid = false;
|
||||
|
@ -87,6 +87,7 @@ public:
|
||||
CompareEqualFunc get_compare_equal_func() const override;
|
||||
CompareLessFunc get_compare_less_func() const override;
|
||||
ObjectID get_object() const override;
|
||||
StringName get_method() const override;
|
||||
int get_argument_count(bool &r_is_valid) const override;
|
||||
void call(const Variant **p_arguments, int p_argcount, Variant &r_return_value, Callable::CallError &r_call_error) const override;
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
# https://github.com/godotengine/godot/issues/94074
|
||||
|
||||
func foo():
|
||||
pass
|
||||
|
||||
func test():
|
||||
var lambda_self := func test() -> void:
|
||||
foo()
|
||||
var anon_lambda_self := func() -> void:
|
||||
foo()
|
||||
|
||||
print(lambda_self.get_method()) # Should print "test".
|
||||
print(anon_lambda_self.get_method()) # Should print "<anonymous lambda>".
|
||||
|
||||
var lambda_non_self := func test() -> void:
|
||||
pass
|
||||
var anon_lambda_non_self := func() -> void:
|
||||
pass
|
||||
|
||||
print(lambda_non_self.get_method()) # Should print "test".
|
||||
print(anon_lambda_non_self.get_method()) # Should print "<anonymous lambda>".
|
@ -0,0 +1,5 @@
|
||||
GDTEST_OK
|
||||
test
|
||||
<anonymous lambda>
|
||||
test
|
||||
<anonymous lambda>
|
Loading…
Reference in New Issue
Block a user