11import type { CallOptions } from '../CallOptions' ;
22import type { DeoptimizableEntity } from '../DeoptimizableEntity' ;
33import type { HasEffectsContext } from '../ExecutionContext' ;
4- import { InclusionContext } from '../ExecutionContext' ;
54import type { NodeEvent } from '../NodeEvents' ;
6- import {
7- type ObjectPath ,
8- type PathTracker ,
9- UNKNOWN_PATH ,
10- UnknownInteger
11- } from '../utils/PathTracker' ;
5+ import { type ObjectPath , type PathTracker , UnknownInteger } from '../utils/PathTracker' ;
126import { UNDEFINED_EXPRESSION , UNKNOWN_LITERAL_NUMBER } from '../values' ;
137import type * as NodeType from './NodeType' ;
148import SpreadElement from './SpreadElement' ;
@@ -20,7 +14,6 @@ import { ObjectEntity, type ObjectProperty } from './shared/ObjectEntity';
2014export default class ArrayExpression extends NodeBase {
2115 declare elements : readonly ( ExpressionNode | SpreadElement | null ) [ ] ;
2216 declare type : NodeType . tArrayExpression ;
23- protected deoptimized = false ;
2417 private objectEntity : ObjectEntity | null = null ;
2518
2619 deoptimizePath ( path : ObjectPath ) : void {
@@ -63,7 +56,7 @@ export default class ArrayExpression extends NodeBase {
6356 ) ;
6457 }
6558
66- hasEffectsWhenAccessedAtPath ( path : ObjectPath , context : HasEffectsContext ) : boolean | undefined {
59+ hasEffectsWhenAccessedAtPath ( path : ObjectPath , context : HasEffectsContext ) : boolean {
6760 return this . getObjectEntity ( ) . hasEffectsWhenAccessedAtPath ( path , context ) ;
6861 }
6962
@@ -79,29 +72,6 @@ export default class ArrayExpression extends NodeBase {
7972 return this . getObjectEntity ( ) . hasEffectsWhenCalledAtPath ( path , callOptions , context ) ;
8073 }
8174
82- includeArgumentsWhenCalledAtPath (
83- path : ObjectPath ,
84- context : InclusionContext ,
85- args : readonly ( ExpressionEntity | SpreadElement ) [ ]
86- ) {
87- this . getObjectEntity ( ) . includeArgumentsWhenCalledAtPath ( path , context , args ) ;
88- }
89-
90- protected applyDeoptimizations ( ) : void {
91- this . deoptimized = true ;
92- let hasSpread = false ;
93- for ( let index = 0 ; index < this . elements . length ; index ++ ) {
94- const element = this . elements [ index ] ;
95- if ( hasSpread || element instanceof SpreadElement ) {
96- if ( element ) {
97- hasSpread = true ;
98- element . deoptimizePath ( UNKNOWN_PATH ) ;
99- }
100- }
101- }
102- this . context . requestTreeshakingPass ( ) ;
103- }
104-
10575 private getObjectEntity ( ) : ObjectEntity {
10676 if ( this . objectEntity !== null ) {
10777 return this . objectEntity ;
@@ -112,7 +82,7 @@ export default class ArrayExpression extends NodeBase {
11282 let hasSpread = false ;
11383 for ( let index = 0 ; index < this . elements . length ; index ++ ) {
11484 const element = this . elements [ index ] ;
115- if ( hasSpread || element instanceof SpreadElement ) {
85+ if ( element instanceof SpreadElement || hasSpread ) {
11686 if ( element ) {
11787 hasSpread = true ;
11888 properties . unshift ( { key : UnknownInteger , kind : 'init' , property : element } ) ;
0 commit comments