type-params is a scope, not a definition

This commit is contained in:
Douglas Creager 2025-12-05 11:51:48 -05:00
parent 2f00ce8834
commit 919941ff59
2 changed files with 23 additions and 12 deletions

View File

@ -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> {

View File

@ -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,15 +12375,20 @@ 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()
.then(|| { || cycle_recovery.is_some()
Box::new(ScopeInferenceExtra { || parameters.is_some()
string_annotations, || return_type.is_some())
cycle_recovery, .then(|| {
diagnostics, Box::new(ScopeInferenceExtra {
}) string_annotations,
}); cycle_recovery,
diagnostics,
parameters,
return_type,
})
});
expressions.shrink_to_fit(); expressions.shrink_to_fit();