Skip to content

Commit

Permalink
Fix issue with missing ancestors when crossing different namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-soares-sky committed Jan 10, 2025
1 parent ce8c570 commit c71189b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/parser/Statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<NamespaceStatement>(isNamespaceStatement);
const namespace = stmt.findAncestor<NamespaceStatement>(isNamespaceStatement);
stmt = state.file.getClassFileLink(
stmt.parentClassName.getName(ParseMode.BrighterScript),
namespace?.getName(ParseMode.BrighterScript)
Expand Down Expand Up @@ -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 [];
Expand Down

0 comments on commit c71189b

Please sign in to comment.