Skip to content

Commit

Permalink
fix: check function's instance class is a subclass of virtual method (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Wyndham authored Jul 23, 2021
1 parent 886a4a6 commit 1958554
Show file tree
Hide file tree
Showing 5 changed files with 5,180 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6947,6 +6947,8 @@ export class Compiler extends DiagnosticEmitter {
// Wouldn't be here if there wasn't at least one overload
var overloadPrototypes = assert(instance.prototype.overloads);

assert(instance.parent.kind == ElementKind.CLASS || instance.parent.kind == ElementKind.INTERFACE);
var parentClassInstance = <Class>instance.parent;
var module = this.module;
var usizeType = this.options.usizeType;
var sizeTypeRef = usizeType.toRef();
Expand Down Expand Up @@ -6992,6 +6994,8 @@ export class Compiler extends DiagnosticEmitter {
if (classInstances) {
for (let _values = Map_values(classInstances), j = 0, l = _values.length; j < l; ++j) {
let classInstance = _values[j];
// Chcek if the parent class is a subtype of instance's class
if (!classInstance.isAssignableTo(parentClassInstance)) continue;
let overloadInstance: Function | null;
if (isProperty) {
let boundProperty = assert(classInstance.members!.get(unboundOverloadParent.name));
Expand Down
5 changes: 5 additions & 0 deletions tests/compiler/class-overloading-cast.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"asc_flags": [
"--explicitStart"
]
}
Loading

0 comments on commit 1958554

Please sign in to comment.