Wire up 'writing' parameter through protected derived class detection (#43455)

Fixes #43443
This commit is contained in:
Ryan Cavanaugh
2021-04-19 09:20:21 -07:00
committed by GitHub
parent e4e96c3399
commit b1ab2b98be
6 changed files with 436 additions and 3 deletions

View File

@@ -19676,8 +19676,8 @@ namespace ts {
// Return true if the given class derives from each of the declaring classes of the protected
// constituents of the given property.
function isClassDerivedFromDeclaringClasses(checkClass: Type, prop: Symbol) {
return forEachProperty(prop, p => getDeclarationModifierFlagsFromSymbol(p) & ModifierFlags.Protected ?
function isClassDerivedFromDeclaringClasses(checkClass: Type, prop: Symbol, writing: boolean) {
return forEachProperty(prop, p => getDeclarationModifierFlagsFromSymbol(p, writing) & ModifierFlags.Protected ?
!hasBaseType(checkClass, getDeclaringClass(p)) : false) ? undefined : checkClass;
}
@@ -26907,7 +26907,7 @@ namespace ts {
// of the property as base classes
let enclosingClass = forEachEnclosingClass(node, enclosingDeclaration => {
const enclosingClass = <InterfaceType>getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration)!);
return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
return isClassDerivedFromDeclaringClasses(enclosingClass, prop, writing) ? enclosingClass : undefined;
});
// A protected property is accessible if the property is within the declaring class or classes derived from it
if (!enclosingClass) {