Skip to content

Commit 47d8d5a

Browse files
authored
Do not deoptimize entire super class when adding a property (#4489)
1 parent 19aef13 commit 47d8d5a

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/ast/nodes/shared/ObjectEntity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class ObjectEntity extends ExpressionEntity {
128128
: this.allProperties) {
129129
property.deoptimizePath(subPath);
130130
}
131-
this.prototypeExpression?.deoptimizePath(path.length === 1 ? [UnknownKey, UnknownKey] : path);
131+
this.prototypeExpression?.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
132132
}
133133

134134
deoptimizeThisOnEventAtPath(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
description: 'does not deoptimize the entire superclass when reassigning a property'
3+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Everything else should be removed
2+
console.log('retained');
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Foo {}
2+
3+
Foo.prototype.bar = {};
4+
5+
class Bar extends Foo {}
6+
7+
Bar.baz = {};
8+
9+
// Everything else should be removed
10+
console.log('retained');

0 commit comments

Comments
 (0)