@@ -2736,13 +2736,6 @@ impl<'db> ClassLiteral<'db> {
2736
2736
// self.name: <annotation>
2737
2737
// self.name: <annotation> = …
2738
2738
2739
- if use_def_map ( db, method_scope)
2740
- . is_declaration_reachable ( db, & attribute_declaration)
2741
- . is_always_false ( )
2742
- {
2743
- continue ;
2744
- }
2745
-
2746
2739
let annotation = declaration_type ( db, declaration) ;
2747
2740
let annotation =
2748
2741
Place :: bound ( annotation. inner ) . with_qualifiers ( annotation. qualifiers ) ;
@@ -2778,8 +2771,6 @@ impl<'db> ClassLiteral<'db> {
2778
2771
continue ;
2779
2772
}
2780
2773
2781
- let method_map = use_def_map ( db, method_scope) ;
2782
-
2783
2774
// The attribute assignment inherits the reachability of the method which contains it
2784
2775
let is_method_reachable =
2785
2776
if let Some ( method_def) = method_scope. node ( db) . as_function ( & module) {
@@ -2799,49 +2790,15 @@ impl<'db> ClassLiteral<'db> {
2799
2790
continue ;
2800
2791
}
2801
2792
2802
- // Storage for the implicit `DefinitionState::Undefined` binding. If present, it
2803
- // will be the first binding in the `attribute_assignments` iterator.
2804
- let mut unbound_binding = None ;
2805
-
2806
2793
for attribute_assignment in attribute_assignments {
2807
2794
if let DefinitionState :: Undefined = attribute_assignment. binding {
2808
- // Store the implicit unbound binding here so that we can delay the
2809
- // computation of `unbound_reachability` to the point when we actually
2810
- // need it. This is an optimization for the common case where the
2811
- // `unbound` binding is the only binding of the `name` attribute,
2812
- // i.e. if there is no `self.name = …` assignment in this method.
2813
- unbound_binding = Some ( attribute_assignment) ;
2814
2795
continue ;
2815
2796
}
2816
2797
2817
2798
let DefinitionState :: Defined ( binding) = attribute_assignment. binding else {
2818
2799
continue ;
2819
2800
} ;
2820
- match method_map
2821
- . is_binding_reachable ( db, & attribute_assignment)
2822
- . and ( is_method_reachable)
2823
- {
2824
- Truthiness :: AlwaysTrue | Truthiness :: Ambiguous => {
2825
- is_attribute_bound = true ;
2826
- }
2827
- Truthiness :: AlwaysFalse => {
2828
- continue ;
2829
- }
2830
- }
2831
-
2832
- // There is at least one attribute assignment that may be reachable, so if `unbound_reachability` is
2833
- // always false then this attribute is considered bound.
2834
- // TODO: this is incomplete logic since the attributes bound after termination are considered reachable.
2835
- let unbound_reachability = unbound_binding
2836
- . as_ref ( )
2837
- . map ( |binding| method_map. is_binding_reachable ( db, binding) )
2838
- . unwrap_or ( Truthiness :: AlwaysFalse ) ;
2839
-
2840
- if unbound_reachability
2841
- . negate ( )
2842
- . and ( is_method_reachable)
2843
- . is_always_true ( )
2844
- {
2801
+ if !is_method_reachable. is_always_false ( ) {
2845
2802
is_attribute_bound = true ;
2846
2803
}
2847
2804
0 commit comments