Skip to content
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

Do not deoptimize entire super class when adding a property #4489

Merged
merged 1 commit into from May 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ast/nodes/shared/ObjectEntity.ts
Expand Up @@ -128,7 +128,7 @@ export class ObjectEntity extends ExpressionEntity {
: this.allProperties) {
property.deoptimizePath(subPath);
}
this.prototypeExpression?.deoptimizePath(path.length === 1 ? [UnknownKey, UnknownKey] : path);
this.prototypeExpression?.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
}

deoptimizeThisOnEventAtPath(
Expand Down
3 changes: 3 additions & 0 deletions test/form/samples/deoptimize-superclass/_config.js
@@ -0,0 +1,3 @@
module.exports = {
description: 'does not deoptimize the entire superclass when reassigning a property'
};
2 changes: 2 additions & 0 deletions test/form/samples/deoptimize-superclass/_expected.js
@@ -0,0 +1,2 @@
// Everything else should be removed
console.log('retained');
10 changes: 10 additions & 0 deletions test/form/samples/deoptimize-superclass/main.js
@@ -0,0 +1,10 @@
class Foo {}

Foo.prototype.bar = {};

class Bar extends Foo {}

Bar.baz = {};

// Everything else should be removed
console.log('retained');