@@ -564,6 +564,12 @@ impl ClassField {
564564 }
565565 }
566566
567+ fn is_non_callable_protocol_method ( & self ) -> bool {
568+ match & self . 0 {
569+ ClassFieldInner :: Simple { ty, .. } => ty. is_non_callable_protocol_method ( ) ,
570+ }
571+ }
572+
567573 pub fn is_foreign_key ( & self ) -> bool {
568574 match & self . 0 {
569575 ClassFieldInner :: Simple { is_foreign_key, .. } => * is_foreign_key,
@@ -2557,16 +2563,43 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
25572563 SuperObj :: Instance ( obj) => self
25582564 . get_super_class_member ( obj. class_object ( ) , Some ( start_lookup_cls) , name)
25592565 . map ( |member| {
2560- self . as_instance_attribute ( & member. value , & Instance :: of_self_type ( obj) )
2566+ if let Some ( reason) = self . super_method_needs_impl_reason ( & member) {
2567+ ClassAttribute :: no_access ( reason)
2568+ } else {
2569+ self . as_instance_attribute ( & member. value , & Instance :: of_self_type ( obj) )
2570+ }
25612571 } ) ,
25622572 SuperObj :: Class ( obj) => self
25632573 . get_super_class_member ( obj. class_object ( ) , Some ( start_lookup_cls) , name)
25642574 . map ( |member| {
2565- self . as_class_attribute ( & member. value , & ClassBase :: SelfType ( obj. clone ( ) ) )
2575+ if let Some ( reason) = self . super_method_needs_impl_reason ( & member) {
2576+ ClassAttribute :: no_access ( reason)
2577+ } else {
2578+ self . as_class_attribute ( & member. value , & ClassBase :: SelfType ( obj. clone ( ) ) )
2579+ }
25662580 } ) ,
25672581 }
25682582 }
25692583
2584+ fn super_method_needs_impl_reason (
2585+ & self ,
2586+ member : & WithDefiningClass < Arc < ClassField > > ,
2587+ ) -> Option < NoAccessReason > {
2588+ if member. value . is_abstract ( ) {
2589+ return Some ( NoAccessReason :: SuperMethodNeedsImplementation (
2590+ member. defining_class . dupe ( ) ,
2591+ ) ) ;
2592+ }
2593+ let metadata = self . get_metadata_for_class ( & member. defining_class ) ;
2594+ if metadata. is_protocol ( ) && member. value . is_non_callable_protocol_method ( ) {
2595+ Some ( NoAccessReason :: SuperMethodNeedsImplementation (
2596+ member. defining_class . dupe ( ) ,
2597+ ) )
2598+ } else {
2599+ None
2600+ }
2601+ }
2602+
25702603 /// Gets an attribute from a class definition.
25712604 ///
25722605 /// Returns `None` if there is no such attribute, otherwise an `Attribute` object
0 commit comments