@@ -411,20 +411,13 @@ export class TraitCompiler implements ProgramTypeCheckAdapter {
411411 }
412412
413413 const symbol = this . makeSymbolForTrait ( trait . handler , clazz , result . analysis ?? null ) ;
414- if ( this . compilationMode !== CompilationMode . LOCAL && result . analysis !== undefined &&
415- trait . handler . register !== undefined ) {
414+ if ( result . analysis !== undefined && trait . handler . register !== undefined ) {
416415 trait . handler . register ( clazz , result . analysis ) ;
417416 }
418417 trait = trait . toAnalyzed ( result . analysis ?? null , result . diagnostics ?? null , symbol ) ;
419418 }
420419
421420 resolve ( ) : void {
422- // No resolving needed for local compilation (only analysis and compile will be done in this
423- // mode)
424- if ( this . compilationMode === CompilationMode . LOCAL ) {
425- return ;
426- }
427-
428421 const classes = this . classes . keys ( ) ;
429422 for ( const clazz of classes ) {
430423 const record = this . classes . get ( clazz ) ! ;
@@ -484,7 +477,7 @@ export class TraitCompiler implements ProgramTypeCheckAdapter {
484477 * `ts.SourceFile`.
485478 */
486479 typeCheck ( sf : ts . SourceFile , ctx : TypeCheckContext ) : void {
487- if ( ! this . fileToClasses . has ( sf ) ) {
480+ if ( ! this . fileToClasses . has ( sf ) || this . compilationMode === CompilationMode . LOCAL ) {
488481 return ;
489482 }
490483
@@ -596,24 +589,20 @@ export class TraitCompiler implements ProgramTypeCheckAdapter {
596589
597590 for ( const trait of record . traits ) {
598591 let compileRes : CompileResult | CompileResult [ ] ;
592+
593+ if ( trait . state !== TraitState . Resolved || containsErrors ( trait . analysisDiagnostics ) ||
594+ containsErrors ( trait . resolveDiagnostics ) ) {
595+ // Cannot compile a trait that is not resolved, or had any errors in its declaration.
596+ continue ;
597+ }
598+
599599 if ( this . compilationMode === CompilationMode . LOCAL ) {
600- if ( trait . state !== TraitState . Analyzed || trait . analysis === null ||
601- containsErrors ( trait . analysisDiagnostics ) ) {
602- // Cannot compile a trait in local mode that is not analyzed, or had any errors in its
603- // declaration.
604- continue ;
605- }
606600 // `trait.analysis` is non-null asserted here because TypeScript does not recognize that
607601 // `Readonly<unknown>` is nullable (as `unknown` itself is nullable) due to the way that
608602 // `Readonly` works.
609- compileRes = trait . handler . compileLocal ( clazz , trait . analysis ! , constantPool ) ;
603+ compileRes =
604+ trait . handler . compileLocal ( clazz , trait . analysis ! , trait . resolution ! , constantPool ) ;
610605 } else {
611- if ( trait . state !== TraitState . Resolved || containsErrors ( trait . analysisDiagnostics ) ||
612- containsErrors ( trait . resolveDiagnostics ) ) {
613- // Cannot compile a trait in global mode that is not resolved, or had any errors in its
614- // declaration.
615- continue ;
616- }
617606 // `trait.resolution` is non-null asserted below because TypeScript does not recognize that
618607 // `Readonly<unknown>` is nullable (as `unknown` itself is nullable) due to the way that
619608 // `Readonly` works.
0 commit comments