@@ -136,7 +136,7 @@ class ClassData {
136
136
return type === 2 /* FieldType.Private */
137
137
|| type === 1 /* FieldType.Protected */ ;
138
138
}
139
- static makeImplicitPublicActuallyPublic ( data ) {
139
+ static makeImplicitPublicActuallyPublic ( data , reportViolation ) {
140
140
// TS-HACK
141
141
// A subtype can make an inherited protected field public. To prevent accidential
142
142
// mangling of public fields we mark the original (protected) fields as public...
@@ -147,7 +147,9 @@ class ClassData {
147
147
let parent = data . parent ;
148
148
while ( parent ) {
149
149
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 } ` ) ;
151
153
parent . fields . get ( name ) . type = 0 /* FieldType.Public */ ;
152
154
}
153
155
parent = parent . parent ;
@@ -361,8 +363,20 @@ class Mangler {
361
363
setupParents ( data ) ;
362
364
}
363
365
// STEP: make implicit public (actually protected) field really public
366
+ const violations = new Map ( ) ;
364
367
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 ( ' , ' ) } ` ) ;
366
380
}
367
381
// STEP: compute replacement names for each class
368
382
for ( const data of this . allClassDataByKey . values ( ) ) {
0 commit comments