Changed assignment logic to not specialize class type on RHS to allow for unspecialized type aliases.

This commit is contained in:
Eric Traut 2020-01-05 11:06:24 -07:00
parent 30eba9b67d
commit 8875b4d2bf

View File

@ -5504,9 +5504,14 @@ export function createTypeEvaluator(importLookup: ImportLookup): TypeEvaluator {
const declaredType = getDeclaredTypeForExpression(node.leftExpression); const declaredType = getDeclaredTypeForExpression(node.leftExpression);
// Evaluate the type of the right-hand side. // Evaluate the type of the right-hand side.
// An assignment of ellipsis means "Any" within a type stub file. // Don't specialize it in case it's a type alias with no specialized
let srcType = getTypeOfExpression(node.rightExpression, declaredType, // type arguments.
fileInfo.isStubFile ? EvaluatorFlags.ConvertEllipsisToAny : undefined).type; let flags: EvaluatorFlags = EvaluatorFlags.DoNotSpecialize;
if (fileInfo.isStubFile) {
// An assignment of ellipsis means "Any" within a type stub file.
flags |= EvaluatorFlags.ConvertEllipsisToAny;
}
let srcType = getTypeOfExpression(node.rightExpression, declaredType, flags).type;
// Determine if the RHS is a constant boolean expression. // Determine if the RHS is a constant boolean expression.
// If so, assign it a literal type. // If so, assign it a literal type.