@@ -136,7 +136,7 @@ class ClassData {
136136 return type === 2 /* FieldType.Private */
137137 || type === 1 /* FieldType.Protected */ ;
138138 }
139- static makeImplicitPublicActuallyPublic ( data ) {
139+ static makeImplicitPublicActuallyPublic ( data , reportViolation ) {
140140 // TS-HACK
141141 // A subtype can make an inherited protected field public. To prevent accidential
142142 // mangling of public fields we mark the original (protected) fields as public...
@@ -147,7 +147,9 @@ class ClassData {
147147 let parent = data . parent ;
148148 while ( parent ) {
149149 if ( parent . fields . get ( name ) ?. type === 1 /* FieldType.Protected */ ) {
150- console . warn ( `WARN: protected became PUBLIC: '${ name } ' defined ${ parent . fileName } #${ info . pos } , PUBLIC via ${ data . fileName } (${ info . pos } )` ) ;
150+ const parentPos = parent . node . getSourceFile ( ) . getLineAndCharacterOfPosition ( parent . fields . get ( name ) . pos ) ;
151+ const infoPos = data . node . getSourceFile ( ) . getLineAndCharacterOfPosition ( info . pos ) ;
152+ reportViolation ( `'${ name } ' from ${ parent . fileName } :${ parentPos . line + 1 } ` , `${ data . fileName } :${ infoPos . line + 1 } ` ) ;
151153 parent . fields . get ( name ) . type = 0 /* FieldType.Public */ ;
152154 }
153155 parent = parent . parent ;
@@ -361,8 +363,20 @@ class Mangler {
361363 setupParents ( data ) ;
362364 }
363365 // STEP: make implicit public (actually protected) field really public
366+ const violations = new Map ( ) ;
364367 for ( const data of this . allClassDataByKey . values ( ) ) {
365- ClassData . makeImplicitPublicActuallyPublic ( data ) ;
368+ ClassData . makeImplicitPublicActuallyPublic ( data , ( what , why ) => {
369+ const arr = violations . get ( what ) ;
370+ if ( arr ) {
371+ arr . push ( why ) ;
372+ }
373+ else {
374+ violations . set ( what , [ why ] ) ;
375+ }
376+ } ) ;
377+ }
378+ for ( const [ why , whys ] of violations ) {
379+ this . log ( `WARN: ${ why } became PUBLIC because of: ${ whys . join ( ' , ' ) } ` ) ;
366380 }
367381 // STEP: compute replacement names for each class
368382 for ( const data of this . allClassDataByKey . values ( ) ) {
0 commit comments