Skip to content

Commit 0b55944

Browse files
stroxlerfacebook-github-bot
authored andcommitted
Clean up some dangling names and comments
Summary: Suggested in review earlier in this stack: always use PossibleLegacyTParam for the names of both keys and bindings, patch up the comments, and fix up the function that gets the Key to use the same naming convention. Reviewed By: rchen152 Differential Revision: D83186813 fbshipit-source-id: f426dc067e7c359cf414abe376aa75cced7b134d
1 parent bf3982f commit 0b55944

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

pyrefly/lib/alt/solve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,7 +1965,7 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
19651965
TypeInfo::of_ty(Type::never())
19661966
}
19671967
}
1968-
Binding::CheckLegacyTypeParam(key, range_if_scoped_params_exist) => {
1968+
Binding::PossibleLegacyTParam(key, range_if_scoped_params_exist) => {
19691969
let ty = match &*self.get_idx(*key) {
19701970
LegacyTypeParameterLookup::Parameter(p) => {
19711971
// This class or function has scoped (PEP 695) type parameters. Mixing legacy-style parameters is an error.
@@ -2270,7 +2270,7 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
22702270
| Binding::Narrow(..)
22712271
| Binding::AssignToAttribute(..)
22722272
| Binding::AssignToSubscript(..)
2273-
| Binding::CheckLegacyTypeParam(..) => {
2273+
| Binding::PossibleLegacyTParam(..) => {
22742274
// These forms require propagating attribute narrowing information, so they
22752275
// are handled in `binding_to_type_info`
22762276
self.binding_to_type_info(binding, errors).into_ty()

pyrefly/lib/binding/binding.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ impl DisplayWith<ModuleInfo> for Key {
459459
Self::Delete(r) => write!(f, "Key::Delete({})", ctx.display(r)),
460460
Self::SelfTypeLiteral(r) => write!(f, "Key::SelfTypeLiteral({})", ctx.display(r)),
461461
Self::PossibleLegacyTParam(r) => {
462-
write!(f, "Key::CheckLegacyTypeParam({})", ctx.display(r))
462+
write!(f, "Key::PossibleLegacyTParam({})", ctx.display(r))
463463
}
464464
Self::PatternNarrow(r) => write!(f, "Key::PatternNarrow({})", ctx.display(r)),
465465
}
@@ -1226,13 +1226,10 @@ pub enum Binding {
12261226
/// with the previous import to this binding (in which case merge the modules).
12271227
Module(ModuleName, Vec<Name>, Option<Idx<Key>>),
12281228
/// A name that might be a legacy type parameter. Solving this gives the Quantified type if so.
1229-
/// The TextRange is optional and should be set at most once per identifier
1230-
/// to avoid duplicate type errors (this is not type safe, because we might
1231-
/// produce multiple `CheckLegacyTypeParam` bindings for the same
1232-
/// identifier).
1233-
/// It controls whether to produce an error saying there are scoped type parameters for this
1234-
/// function / class, and therefore the use of legacy type parameters is invalid.
1235-
CheckLegacyTypeParam(Idx<KeyLegacyTypeParam>, Option<TextRange>),
1229+
/// The TextRange is optional and controls whether to produce an error
1230+
/// saying there are scoped type parameters for this function / class, and
1231+
/// therefore the use of legacy type parameters is invalid.
1232+
PossibleLegacyTParam(Idx<KeyLegacyTypeParam>, Option<TextRange>),
12361233
/// An assignment to a name.
12371234
NameAssign(
12381235
Name,
@@ -1371,8 +1368,8 @@ impl DisplayWith<Bindings> for Binding {
13711368
Self::TypeParameter(tp) => {
13721369
write!(f, "TypeParameter({}, {}, ..)", tp.unique, tp.kind)
13731370
}
1374-
Self::CheckLegacyTypeParam(k, _) => {
1375-
write!(f, "CheckLegacyTypeParam({})", ctx.display(*k))
1371+
Self::PossibleLegacyTParam(k, _) => {
1372+
write!(f, "PossibleLegacyTParam({})", ctx.display(*k))
13761373
}
13771374
Self::AnnotatedType(k1, k2) => {
13781375
write!(
@@ -1549,7 +1546,7 @@ impl Binding {
15491546
| Binding::ParamSpec(_, _, _)
15501547
| Binding::TypeVarTuple(_, _, _)
15511548
| Binding::TypeParameter(_)
1552-
| Binding::CheckLegacyTypeParam(_, _) => Some(SymbolKind::TypeParameter),
1549+
| Binding::PossibleLegacyTParam(_, _) => Some(SymbolKind::TypeParameter),
15531550
Binding::Global(_) => Some(SymbolKind::Variable),
15541551
Binding::Function(_, _, _) => Some(SymbolKind::Function),
15551552
Binding::Import(_, _, _) => {

pyrefly/lib/binding/bindings.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ impl LegacyTParamId {
979979
/// Note that the range here is not the range of the full `LegacyTParamId`, but
980980
/// just of the name being bound (which in the `Attr` case is just the base
981981
/// rather than the entire identifier).
982-
fn as_check_legacy_tparam_key(&self) -> Key {
982+
fn as_possible_legacy_tparam_key(&self) -> Key {
983983
Key::PossibleLegacyTParam(self.as_identifier().range)
984984
}
985985

@@ -1145,8 +1145,8 @@ impl<'a> BindingsBuilder<'a> {
11451145
let tparam_idx = Self::make_legacy_tparam(&id, original_binding, original_idx)
11461146
.map(|(k, v)| self.insert_binding(k, v))?;
11471147
let idx = self.insert_binding(
1148-
id.as_check_legacy_tparam_key(),
1149-
Binding::CheckLegacyTypeParam(
1148+
id.as_possible_legacy_tparam_key(),
1149+
Binding::PossibleLegacyTParam(
11501150
tparam_idx,
11511151
if has_scoped_type_params {
11521152
Some(id.range())

pyrefly/lib/state/ide.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn find_definition_key_from<'a>(bindings: &'a Bindings, key: &'a Key) -> Option<
7777
current_idx = *k;
7878
}
7979
Binding::Phi(ks) if !ks.is_empty() => current_idx = *ks.iter().next().unwrap(),
80-
Binding::CheckLegacyTypeParam(k, _) => {
80+
Binding::PossibleLegacyTParam(k, _) => {
8181
let binding = bindings.get(*k);
8282
current_idx = binding.idx();
8383
}
@@ -114,7 +114,7 @@ fn create_intermediate_definition_from(
114114
while !gas.stop() {
115115
match current_binding {
116116
Binding::Forward(k) => current_binding = bindings.get(*k),
117-
Binding::CheckLegacyTypeParam(k, _) => {
117+
Binding::PossibleLegacyTParam(k, _) => {
118118
let binding = bindings.get(*k);
119119
current_binding = bindings.get(binding.idx());
120120
}

0 commit comments

Comments
 (0)