Merge pull request #70229 from adamscott/fix-class-lookup

Fix outer class lookup
This commit is contained in:
Rémi Verschelde 2022-12-18 00:11:56 +01:00
commit 2ee88192f9
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 15 additions and 1 deletions

View file

@ -3167,7 +3167,7 @@ void GDScriptAnalyzer::reduce_identifier_from_base(GDScriptParser::IdentifierNod
// TODO: Allow outer static functions.
if (base_class->outer != nullptr) {
List<GDScriptParser::ClassNode *> script_classes;
get_class_node_current_scope_classes(parser->current_class, &script_classes);
get_class_node_current_scope_classes(base_class->outer, &script_classes);
for (GDScriptParser::ClassNode *script_class : script_classes) {
if (script_class->has_member(name)) {
resolve_class_member(script_class, name, p_identifier);

View file

@ -0,0 +1,12 @@
class A:
class B:
func test():
print(A.B.D)
class C:
class D:
pass
func test():
var inst = A.B.new()
inst.test()

View file

@ -0,0 +1,2 @@
GDTEST_ANALYZER_ERROR
Cannot find member "D" in base "B".