Changed type logic to allow type to be assigned to Type[T]. In this case, type is treated the same as Type[Any], so T receives a value of Any.

This commit is contained in:
Eric Traut 2021-12-18 18:34:48 -07:00
parent 998a016f69
commit 836a1fcf9b

View File

@ -18751,6 +18751,16 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
} }
} }
// If we're attempting to assign `type` to Type[T], transform `type` into `Type[Any]`.
if (
TypeBase.isInstantiable(destType) &&
isClassInstance(srcType) &&
ClassType.isBuiltIn(srcType, 'type') &&
!srcType.typeArguments
) {
srcType = AnyType.create();
}
const curEntry = typeVarMap.getTypeVar(destType); const curEntry = typeVarMap.getTypeVar(destType);
const curNarrowTypeBound = curEntry?.narrowBound; const curNarrowTypeBound = curEntry?.narrowBound;
const curWideTypeBound = curEntry?.wideBound ?? destType.details.boundType; const curWideTypeBound = curEntry?.wideBound ?? destType.details.boundType;