@@ -74,18 +74,8 @@ export class TypeUtils {
7474 static canAssignType ( destType : Type , srcType : Type , typeVarMap ?: TypeVarMap ,
7575 recursionCount = 0 ) : boolean {
7676
77- if ( destType . isAny ( ) || srcType . isAny ( ) ) {
78- return true ;
79- }
80-
81- if ( srcType instanceof TypeVarType ) {
82- // This should happen only if we have a bug and forgot to specialize
83- // the source type or the code being analyzed contains a bug where
84- // a return type uses a type var that is not referenced elswhere
85- // in a function.
86- return false ;
87- }
88-
77+ // Before performing any other checks, see if the dest type is a
78+ // TypeVar that we are attempting to match.
8979 if ( destType instanceof TypeVarType ) {
9080 // If the dest type includes type variables, it is not yet
9181 // specialized, so the caller should have provided a typeVarMap.
@@ -101,6 +91,18 @@ export class TypeUtils {
10191 return this . _canAssignToTypeVar ( destType , srcType ) ;
10292 }
10393
94+ if ( srcType instanceof TypeVarType ) {
95+ // This should happen only if we have a bug and forgot to specialize
96+ // the source type or the code being analyzed contains a bug where
97+ // a return type uses a type var that is not referenced elswhere
98+ // in a function.
99+ return false ;
100+ }
101+
102+ if ( destType . isAny ( ) || srcType . isAny ( ) ) {
103+ return true ;
104+ }
105+
104106 if ( recursionCount > MaxCanAssignTypeRecursion ) {
105107 return true ;
106108 }
0 commit comments