fix completions protected members in recursive generic types (#19192) (#19242)

This commit is contained in:
wenlu.wang 2017-11-08 19:44:12 -06:00 committed by Mohamed Hegazy
parent 1408a4d2b7
commit e9841f3899
2 changed files with 21 additions and 4 deletions

View file

@ -15162,12 +15162,11 @@ namespace ts {
if (flags & ModifierFlags.Static) {
return true;
}
// An instance property must be accessed through an instance of the enclosing class
if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) {
if (type.flags & TypeFlags.TypeParameter) {
// get the original type -- represented as the type constraint of the 'this' type
type = getConstraintOfTypeParameter(<TypeParameter>type);
type = (type as TypeParameter).isThisType ? getConstraintOfTypeParameter(<TypeParameter>type) : getBaseConstraintOfType(<TypeParameter>type);
}
if (!(getObjectFlags(getTargetType(type)) & ObjectFlags.ClassOrInterface && hasBaseType(type, enclosingClass))) {
if (!type || !hasBaseType(type, enclosingClass)) {
error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
return false;
}

View file

@ -0,0 +1,18 @@
/// <reference path="fourslash.ts" />
//// export class TestBase<T extends TestBase<T>>
//// {
//// public publicMethod(p: any): void {}
//// private privateMethod(p: any): void {}
//// protected protectedMethod(p: any): void {}
//// public test(t: T): void
//// {
//// t./**/
//// }
//// }
goTo.marker();
verify.completionListContains('publicMethod');
verify.completionListContains('privateMethod');
verify.completionListContains('protectedMethod');