Fixed bug that results in a spurious reportAbstractUsage error when an abstract class is captured through a type[T]. This addresses #7680. (#7681)

This commit is contained in:
Eric Traut 2024-04-12 23:10:30 -07:00 committed by GitHub
parent 92f2284d24
commit dfe428190c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4267,21 +4267,21 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
// it represents an instance of a type. If the replacement includes
// a generic class that has not been specialized, specialize it
// now with default type arguments.
if (this._options.unknownIfNotFound) {
replacement = mapSubtypes(replacement, (subtype) => {
if (isClassInstance(subtype)) {
// If the includeSubclasses wasn't set, force it to be set by
// converting to/from an instantiable.
if (!subtype.includeSubclasses) {
subtype = ClassType.cloneAsInstance(ClassType.cloneAsInstantiable(subtype));
}
return specializeWithDefaultTypeArgs(subtype);
replacement = mapSubtypes(replacement, (subtype) => {
if (isClassInstance(subtype)) {
// If the includeSubclasses wasn't set, force it to be set by
// converting to/from an instantiable.
if (!subtype.includeSubclasses) {
subtype = ClassType.cloneAsInstance(ClassType.cloneAsInstantiable(subtype));
}
return subtype;
});
}
if (this._options.unknownIfNotFound) {
return specializeWithDefaultTypeArgs(subtype);
}
}
return subtype;
});
}
if (isTypeVar(replacement) && typeVar.isVariadicUnpacked && replacement.details.isVariadic) {