Skip to content

Commit

Permalink
Merge branch 'main' into pull-pylance-with-pyright-1.1.369-9716881771
Browse files Browse the repository at this point in the history
  • Loading branch information
rchiodo authored Jun 29, 2024
2 parents 1fde529 + bee1d91 commit 9813f9e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19499,6 +19499,16 @@ export function createTypeEvaluator(
continue;
}

// Forward-declared type annotation expressions need to be be evaluated
// in context so they have the appropriate flags set. Most of these cases
// will have been detected above when calling getParentAnnotationNode,
// but TypeAlias expressions are not handled there.
const stringEnclosure = ParseTreeUtils.getParentNodeOfType(parent, ParseNodeType.StringList);
if (stringEnclosure) {
nodeToEvaluate = stringEnclosure as StringListNode;
continue;
}

// The left expression of a call or member access expression is not generally contextual.
if (parent.nodeType === ParseNodeType.Call || parent.nodeType === ParseNodeType.MemberAccess) {
if (nodeToEvaluate === parent.leftExpression) {
Expand All @@ -19525,15 +19535,7 @@ export function createTypeEvaluator(
// The base expression of an index expression is not contextual.
if (nodeToEvaluate === parent.baseExpression) {
flags = EvaluatorFlags.IndexBaseDefaults;
break;
}
} else if (parent.nodeType === ParseNodeType.StringList && nodeToEvaluate === parent.typeAnnotation) {
// Forward-declared type annotation expressions need to be be evaluated
// in context so they have the appropriate flags set. Most of these cases
// will have been detected above when calling getParentAnnotationNode,
// but TypeAlias expressions are not handled there.
nodeToEvaluate = parent;
continue;
}

if (!isExpressionNode(parent)) {
Expand Down

0 comments on commit 9813f9e

Please sign in to comment.