[ty] Add generic inference for dataclasses (#18443)
## Summary An issue seen here https://github.com/astral-sh/ty/issues/500 The `__init__` method of dataclasses had no inherited generic context, so we could not infer the type of an instance from a constructor call with generics ## Test Plan Add tests to classes.md` in generics folder
This commit is contained in:
@@ -1372,7 +1372,8 @@ impl<'db> ClassLiteral<'db> {
|
||||
parameters.push(parameter);
|
||||
}
|
||||
|
||||
let signature = Signature::new(Parameters::new(parameters), Some(Type::none(db)));
|
||||
let mut signature = Signature::new(Parameters::new(parameters), Some(Type::none(db)));
|
||||
signature.inherited_generic_context = self.generic_context(db);
|
||||
Some(CallableType::function_like(db, signature))
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user