Fix this.member completion+quickinfo of overloads

1. Completion after `this.` was empty.
2. Quick info of methods with overloads always chose the first overload,
regardless of whether an argument whose type matched a different overload.

Both have the same cause: the type parameter introduced by
polymorphic `this` is not usable, whereas the original is. In both cases,
the usage is simple -- it doesn't take advantage of the capabilities of
polymorphic `this`.
This commit is contained in:
Nathan Shively-Sanders 2015-10-08 08:11:33 -07:00
parent 78ad0f4c82
commit 2fb6eabc2e
2 changed files with 6 additions and 1 deletions

View file

@ -7977,6 +7977,11 @@ namespace ts {
return true;
}
// An instance property must be accessed through an instance of the enclosing class
if (type.flags & TypeFlags.ThisType) {
// get the original type -- represented as the type constraint of the this type
type = getConstraintOfTypeParameter(<TypeParameter>type);
}
// TODO: why is the first part of this check here?
if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(<InterfaceType>type, enclosingClass))) {
error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));

View file

@ -4105,7 +4105,7 @@ namespace ts {
let useConstructSignatures = callExpression.kind === SyntaxKind.NewExpression || callExpression.expression.kind === SyntaxKind.SuperKeyword;
let allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures();
if (!contains(allSignatures, signature.target || signature)) {
if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) {
// Get the first signature if there
signature = allSignatures.length ? allSignatures[0] : undefined;
}