From c71189bc4ac908707ce6cdddd418989dce7d9a5f Mon Sep 17 00:00:00 2001 From: Luis Soares Date: Fri, 10 Jan 2025 15:24:34 +0000 Subject: [PATCH] Fix issue with missing ancestors when crossing different namespaces --- src/parser/Statement.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/parser/Statement.ts b/src/parser/Statement.ts index e2d45e902..b0b2011a1 100644 --- a/src/parser/Statement.ts +++ b/src/parser/Statement.ts @@ -2144,7 +2144,7 @@ export class ClassStatement extends Statement implements TypedefProvider { let stmt = this as ClassStatement; while (stmt) { if (stmt.parentClassName) { - const namespace = this.findAncestor(isNamespaceStatement); + const namespace = stmt.findAncestor(isNamespaceStatement); stmt = state.file.getClassFileLink( stmt.parentClassName.getName(ParseMode.BrighterScript), namespace?.getName(ParseMode.BrighterScript) @@ -2180,13 +2180,9 @@ export class ClassStatement extends Statement implements TypedefProvider { */ private getConstructorParams(ancestors: ClassStatement[]) { for (let ancestor of ancestors) { - // @todo: somehow, ancestors can have a list where the last element is null. - // this is exposed by the test named "extending namespaced class transpiles properly". - if (ancestor) { - const ctor = ancestor.getConstructorFunction(); - if (ctor) { - return ctor.func.parameters; - } + const ctor = ancestor?.getConstructorFunction(); + if (ctor) { + return ctor.func.parameters; } } return [];