GDScript: Fix "Identifier not found" error when accessing inner class from inside

This commit is contained in:
Danil Alexeev 2023-08-11 11:22:01 +03:00
parent 7df393312f
commit fb45cab133
No known key found for this signature in database
GPG key ID: 124453E157DA8DC7
3 changed files with 29 additions and 0 deletions

View file

@ -3469,6 +3469,9 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
for (GDScriptParser::ClassNode *script_class : script_classes) {
if (p_base == nullptr && script_class->identifier && script_class->identifier->name == name) {
reduce_identifier_from_base_set_class(p_identifier, script_class->get_datatype());
if (script_class->outer != nullptr) {
p_identifier->source = GDScriptParser::IdentifierNode::MEMBER_CLASS;
}
return;
}

View file

@ -0,0 +1,21 @@
# GH-80508
class A:
func a():
return A.new()
func b():
return B.new()
class B:
func a():
return A.new()
func b():
return B.new()
func test():
var a := A.new()
var b := B.new()
print(a.a() is A)
print(a.b() is B)
print(b.a() is A)
print(b.b() is B)

View file

@ -0,0 +1,5 @@
GDTEST_OK
true
true
true
true