Fixed bug that caused duplicate diagnostics to be reported for quoted type annotations in some cases.

This commit is contained in:
Eric Traut 2020-07-28 08:28:29 -07:00
parent 51fd428596
commit fdca53a939

View File

@ -702,6 +702,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
checkForCancellation(); checkForCancellation();
let typeResult: TypeResult | undefined; let typeResult: TypeResult | undefined;
let reportExpectingTypeErrors = (flags & EvaluatorFlags.ExpectingType) !== 0;
switch (node.nodeType) { switch (node.nodeType) {
case ParseNodeType.Name: { case ParseNodeType.Name: {
@ -769,6 +770,10 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
); );
typeResult = { node, type: UnknownType.create() }; typeResult = { node, type: UnknownType.create() };
} }
// Don't report expecting type errors again. We will have already
// reported them when analyzing the contents of the string.
reportExpectingTypeErrors = false;
} else { } else {
// Evaluate the format string expressions in this context. // Evaluate the format string expressions in this context.
node.strings.forEach((str) => { node.strings.forEach((str) => {
@ -941,7 +946,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
fail(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`); fail(`Unhandled expression type '${ParseTreeUtils.printExpression(node)}'`);
} }
if (flags & EvaluatorFlags.ExpectingType) { if (reportExpectingTypeErrors) {
const resultType = transformTypeObjectToClass(typeResult.type); const resultType = transformTypeObjectToClass(typeResult.type);
if (!TypeBase.isInstantiable(resultType)) { if (!TypeBase.isInstantiable(resultType)) {
const isEmptyTuple = const isEmptyTuple =