mirror of https://github.com/astral-sh/ruff
type-params is a scope, not a definition
This commit is contained in:
parent
2f00ce8834
commit
919941ff59
|
|
@ -547,6 +547,12 @@ struct ScopeInferenceExtra<'db> {
|
||||||
|
|
||||||
/// The diagnostics for this region.
|
/// The diagnostics for this region.
|
||||||
diagnostics: TypeCheckDiagnostics,
|
diagnostics: TypeCheckDiagnostics,
|
||||||
|
|
||||||
|
/// The parameters of a function definition (without any default values filled in).
|
||||||
|
parameters: Option<Vec<Parameter<'db>>>,
|
||||||
|
|
||||||
|
/// The return type of a function definition.
|
||||||
|
return_type: Option<Type<'db>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'db> ScopeInference<'db> {
|
impl<'db> ScopeInference<'db> {
|
||||||
|
|
|
||||||
|
|
@ -12347,17 +12347,17 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
||||||
mut expressions,
|
mut expressions,
|
||||||
scope,
|
scope,
|
||||||
cycle_recovery,
|
cycle_recovery,
|
||||||
|
parameters,
|
||||||
|
return_type,
|
||||||
|
|
||||||
// Ignored, because scope types are never extended into other scopes.
|
// Ignored, because scope types are never extended into other scopes.
|
||||||
deferred: _,
|
deferred: _,
|
||||||
bindings: _,
|
bindings: _,
|
||||||
declarations: _,
|
declarations: _,
|
||||||
|
parameter_defaults: _,
|
||||||
|
|
||||||
// Ignored; only relevant to definition regions
|
// Ignored; only relevant to definition regions
|
||||||
undecorated_type: _,
|
undecorated_type: _,
|
||||||
parameters: _,
|
|
||||||
parameter_defaults: _,
|
|
||||||
return_type: _,
|
|
||||||
|
|
||||||
// Builder only state
|
// Builder only state
|
||||||
dataclass_field_specifiers: _,
|
dataclass_field_specifiers: _,
|
||||||
|
|
@ -12375,13 +12375,18 @@ impl<'db, 'ast> TypeInferenceBuilder<'db, 'ast> {
|
||||||
let _ = scope;
|
let _ = scope;
|
||||||
let diagnostics = context.finish();
|
let diagnostics = context.finish();
|
||||||
|
|
||||||
let extra =
|
let extra = (!string_annotations.is_empty()
|
||||||
(!string_annotations.is_empty() || !diagnostics.is_empty() || cycle_recovery.is_some())
|
|| !diagnostics.is_empty()
|
||||||
|
|| cycle_recovery.is_some()
|
||||||
|
|| parameters.is_some()
|
||||||
|
|| return_type.is_some())
|
||||||
.then(|| {
|
.then(|| {
|
||||||
Box::new(ScopeInferenceExtra {
|
Box::new(ScopeInferenceExtra {
|
||||||
string_annotations,
|
string_annotations,
|
||||||
cycle_recovery,
|
cycle_recovery,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
|
parameters,
|
||||||
|
return_type,
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue