mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 13:41:03 +00:00 
			
		
		
		
	GDScript: Fix accessing static function as Callable in static context
				
					
				
			This commit is contained in:
		
							parent
							
								
									84692c6252
								
							
						
					
					
						commit
						10dcb21d8b
					
				
					 3 changed files with 15 additions and 3 deletions
				
			
		|  | @ -322,9 +322,13 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code | ||||||
| 								if (member.type == GDScriptParser::ClassNode::Member::FUNCTION || member.type == GDScriptParser::ClassNode::Member::SIGNAL) { | 								if (member.type == GDScriptParser::ClassNode::Member::FUNCTION || member.type == GDScriptParser::ClassNode::Member::SIGNAL) { | ||||||
| 									// Get like it was a property.
 | 									// Get like it was a property.
 | ||||||
| 									GDScriptCodeGenerator::Address temp = codegen.add_temporary(); // TODO: Get type here.
 | 									GDScriptCodeGenerator::Address temp = codegen.add_temporary(); // TODO: Get type here.
 | ||||||
| 									GDScriptCodeGenerator::Address self(GDScriptCodeGenerator::Address::SELF); |  | ||||||
| 
 | 
 | ||||||
| 									gen->write_get_named(temp, identifier, self); | 									GDScriptCodeGenerator::Address base(GDScriptCodeGenerator::Address::SELF); | ||||||
|  | 									if (member.type == GDScriptParser::ClassNode::Member::FUNCTION && member.function->is_static) { | ||||||
|  | 										base = GDScriptCodeGenerator::Address(GDScriptCodeGenerator::Address::CLASS); | ||||||
|  | 									} | ||||||
|  | 
 | ||||||
|  | 									gen->write_get_named(temp, identifier, base); | ||||||
| 									return temp; | 									return temp; | ||||||
| 								} | 								} | ||||||
| 							} | 							} | ||||||
|  |  | ||||||
|  | @ -1,12 +1,18 @@ | ||||||
| # GH-79521 | # GH-79521, GH-86032 | ||||||
| 
 | 
 | ||||||
| class_name TestStaticMethodAsCallable | class_name TestStaticMethodAsCallable | ||||||
| 
 | 
 | ||||||
| static func static_func() -> String: | static func static_func() -> String: | ||||||
| 	return "Test" | 	return "Test" | ||||||
| 
 | 
 | ||||||
|  | static func another_static_func(): | ||||||
|  | 	prints("another_static_func:", static_func.call(), static_func.is_valid()) | ||||||
|  | 
 | ||||||
| func test(): | func test(): | ||||||
| 	var a: Callable = TestStaticMethodAsCallable.static_func | 	var a: Callable = TestStaticMethodAsCallable.static_func | ||||||
| 	var b: Callable = static_func | 	var b: Callable = static_func | ||||||
| 	prints(a.call(), a.is_valid()) | 	prints(a.call(), a.is_valid()) | ||||||
| 	prints(b.call(), b.is_valid()) | 	prints(b.call(), b.is_valid()) | ||||||
|  | 	@warning_ignore("static_called_on_instance") | ||||||
|  | 	another_static_func() | ||||||
|  | 	TestStaticMethodAsCallable.another_static_func() | ||||||
|  |  | ||||||
|  | @ -1,3 +1,5 @@ | ||||||
| GDTEST_OK | GDTEST_OK | ||||||
| Test true | Test true | ||||||
| Test true | Test true | ||||||
|  | another_static_func: Test true | ||||||
|  | another_static_func: Test true | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Danil Alexeev
						Danil Alexeev