@@ -852,33 +852,25 @@ namespace ts {
852852 function addPrologueDirectivesAndInitialSuperCall ( ctor : ConstructorDeclaration , result : Statement [ ] ) : number {
853853 if ( ctor . body ) {
854854 const statements = ctor . body . statements ;
855- // find first statement that is not prologue directive
856- let indexOfFirstNonPrologueDirective = - 1 ;
857- for ( let i = 0 ; i < statements . length ; i ++ ) {
858- if ( ! isPrologueDirective ( statements [ i ] ) ) {
859- indexOfFirstNonPrologueDirective = i ;
860- break ;
861- }
862- }
863-
864- if ( indexOfFirstNonPrologueDirective === - 1 ) {
865- return 0 ;
855+ // add prologue directives to the list (if any)
856+ const index = addPrologueDirectives ( result , statements ) ;
857+ if ( index === statements . length ) {
858+ // list contains nothing but prologue directives (or empty) - exit
859+ return index ;
866860 }
867861
868- const statement = statements [ indexOfFirstNonPrologueDirective ] ;
862+ const statement = statements [ index ] ;
869863 if ( statement . kind === SyntaxKind . ExpressionStatement ) {
870864 const expression = ( < ExpressionStatement > statement ) . expression ;
871865 if ( expression . kind === SyntaxKind . CallExpression ) {
872866 if ( ( < CallExpression > expression ) . expression . kind === SyntaxKind . SuperKeyword ) {
873- for ( let i = 0 ; i < indexOfFirstNonPrologueDirective ; i ++ ) {
874- // push all non-prologue directives
875- result . push ( statements [ i ] ) ;
876- }
877867 result . push ( visitNode ( statement , visitor , isStatement ) ) ;
878- return indexOfFirstNonPrologueDirective + 1 ;
868+ return index + 1 ;
879869 }
880870 }
881871 }
872+
873+ return index ;
882874 }
883875
884876 return 0 ;
0 commit comments