Skip to content

Defuse assertion when mixing managed and unmanaged classes #2071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9614,7 +9614,10 @@ function ensureVisitMembersOf(compiler: Compiler, instance: Class): void {
);

// And make sure the base visitor function exists
if (base) ensureVisitMembersOf(compiler, base);
if (base && base.type.isManaged) {
// errored earlier if not managed
ensureVisitMembersOf(compiler, base);
}
}

/** Compiles the `__visit_members` function. */
Expand Down
9 changes: 9 additions & 0 deletions tests/compiler/unmanaged-errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"asc_flags": [
],
"stderr": [
"AS207: Unmanaged classes cannot extend managed classes and vice-versa.", "UnmanagedFoo extends ManagedBase",
"AS207: Unmanaged classes cannot extend managed classes and vice-versa.", "ManagedFoo extends UnmanagedBase",
"EOF"
]
}
12 changes: 12 additions & 0 deletions tests/compiler/unmanaged-errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export class ManagedBase {}
@unmanaged export class UnmanagedFoo extends ManagedBase {} // AS207

// see: https://github.com/AssemblyScript/assemblyscript/issues/2067

@unmanaged export class UnmanagedBase {}
export class ManagedBaz {}
export class ManagedFoo extends UnmanagedBase { // AS207
constructor(public baz: ManagedBaz) { super(); }
}

ERROR("EOF");