Merge pull request #5169 from Microsoft/fix-simple-uses-of-polymorphic-this-in-services

Fix simple uses of polymorphic this in services
This commit is contained in:
Nathan Shively-Sanders
2015-10-12 13:54:50 -07:00
6 changed files with 54 additions and 48 deletions
+5
View File
@@ -7984,6 +7984,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));
+3 -2
View File
@@ -4112,8 +4112,9 @@ 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)) {
// Get the first signature if there
if (!contains(allSignatures, signature.target) && !contains(allSignatures, signature)) {
// Get the first signature if there is one -- allSignatures may contain
// either the original signature or its target, so check for either
signature = allSignatures.length ? allSignatures[0] : undefined;
}