@@ -7110,6 +7110,13 @@ export class Compiler extends DiagnosticEmitter {
71107110 // Compile the called function's body in the scope of the inlined flow
71117111 this . compileFunctionBody ( instance , body ) ;
71127112
7113+ // If a constructor, perform field init checks on its flow directly
7114+ if ( instance . is ( CommonFlags . CONSTRUCTOR ) ) {
7115+ let parent = instance . parent ;
7116+ assert ( parent . kind == ElementKind . CLASS ) ;
7117+ this . checkFieldInitializationInFlow ( < Class > parent , flow ) ;
7118+ }
7119+
71137120 // Free any new scoped locals and reset to the original flow
71147121 if ( ! flow . is ( FlowFlags . TERMINATES ) ) {
71157122 this . performAutoreleases ( flow , body ) ;
@@ -9326,7 +9333,11 @@ export class Compiler extends DiagnosticEmitter {
93269333 if ( ! classInstance ) return module . unreachable ( ) ;
93279334 if ( contextualType == Type . void ) constraints |= Constraints . WILL_DROP ;
93289335 var ctor = this . ensureConstructor ( classInstance , expression ) ;
9329- this . checkFieldInitialization ( classInstance , expression ) ;
9336+ if ( ! ctor . hasDecorator ( DecoratorFlags . INLINE ) ) {
9337+ // Inlined ctors haven't been compiled yet and are checked upon inline
9338+ // compilation of their body instead.
9339+ this . checkFieldInitialization ( classInstance , expression ) ;
9340+ }
93309341 return this . compileInstantiate ( ctor , expression . args , constraints , expression ) ;
93319342 }
93329343
@@ -9453,10 +9464,14 @@ export class Compiler extends DiagnosticEmitter {
94539464 checkFieldInitialization ( classInstance : Class , relatedNode : Node | null = null ) : void {
94549465 if ( classInstance . didCheckFieldInitialization ) return ;
94559466 classInstance . didCheckFieldInitialization = true ;
9467+ var ctor = assert ( classInstance . constructorInstance ) ;
9468+ this . checkFieldInitializationInFlow ( classInstance , ctor . flow , relatedNode ) ;
9469+ }
9470+
9471+ /** Checks that all class fields have been initialized in the specified flow. */
9472+ checkFieldInitializationInFlow ( classInstance : Class , flow : Flow , relatedNode : Node | null = null ) : void {
94569473 var members = classInstance . members ;
94579474 if ( members ) {
9458- let ctor = assert ( classInstance . constructorInstance ) ;
9459- let flow = ctor . flow ;
94609475 for ( let _values = Map_values ( members ) , i = 0 , k = _values . length ; i < k ; ++ i ) {
94619476 let element = _values [ i ] ;
94629477 if ( element . kind == ElementKind . FIELD && element . parent == classInstance ) {
0 commit comments