diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 38bc617c650..6f75bfa0d46 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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(type); + type = (type as TypeParameter).isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(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; } diff --git a/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts b/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts new file mode 100644 index 00000000000..993b9eb73ac --- /dev/null +++ b/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts @@ -0,0 +1,18 @@ +/// + +//// export class TestBase> +//// { +//// 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');