[ty] Add a subdiagnostic if invalid-return-type is emitted on a method with an empty body on a non-protocol subclass of a protocol class (#18243)

This commit is contained in:
Alex Waygood 2025-05-21 13:38:07 -04:00 committed by GitHub
parent da4be789ef
commit 41463396cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 178 additions and 65 deletions

View file

@ -546,6 +546,13 @@ impl NodeWithScopeKind {
}
}
pub(crate) const fn as_class(&self) -> Option<&ast::StmtClassDef> {
match self {
Self::Class(class) => Some(class.node()),
_ => None,
}
}
pub fn expect_function(&self) -> &ast::StmtFunctionDef {
self.as_function().expect("expected function")
}