Skip to content

Commit

Permalink
Do not deoptimize entire super class when adding a property (#4489)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed May 7, 2022
1 parent 19aef13 commit 47d8d5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
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');

0 comments on commit 47d8d5a

Please sign in to comment.