Skip to content

Commit

Permalink
Merge branch 'master' into feature/as_custom_type
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Jan 12, 2021
2 parents c2cf523 + 34a86d3 commit 2a2e34c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
40 changes: 40 additions & 0 deletions src/files/BrsFile.Class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -949,4 +949,44 @@ describe('BrsFile BrighterScript classes', () => {
await program.validate();
expectZeroDiagnostics(program);
});

it('computes correct super index for grandchild class', async () => {
await program.addOrReplaceFile('source/main.bs', `
sub Main()
c = new App.ClassC()
end sub
namespace App
class ClassA
end class
class ClassB extends ClassA
end class
end namespace
`);

await testTranspile(`
namespace App
class ClassC extends ClassB
sub new()
super()
end sub
end class
end namespace
`, `
function __App_ClassC_builder()
instance = __App_ClassB_builder()
instance.super1_new = instance.new
instance.new = sub()
m.super1_new()
end sub
return instance
end function
function App_ClassC()
instance = __App_ClassC_builder()
instance.new()
return instance
end function
`, 'trim', 'source/App.ClassC.bs');
});
});
6 changes: 5 additions & 1 deletion src/parser/Statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,11 @@ export class ClassStatement extends Statement implements TypedefProvider {
let stmt = this as ClassStatement;
while (stmt) {
if (stmt.parentClassName) {
stmt = state.file.getClassByName(stmt.parentClassName.getName(ParseMode.BrighterScript));
const fqParentClassName = util.getFullyQualifiedClassName(
stmt.parentClassName.getName(ParseMode.BrighterScript),
stmt.namespaceName?.getName(ParseMode.BrighterScript)
);
stmt = state.file.getClassByName(fqParentClassName);
myIndex++;
} else {
break;
Expand Down

0 comments on commit 2a2e34c

Please sign in to comment.