8 #include "ast/AstNode.h"
9 #include "diagnostics/Diagnostics.h"
17 void Check(ast::LinkingUnit
const* lu) {
22 bool isSubtype(ast::
Type const* sub, ast::
Type const* super);
25 bool isSuperClass(ast::ClassDecl
const* super, ast::ClassDecl
const* sub);
28 bool isSuperInterface(ast::InterfaceDecl
const* super, ast::
Decl const* sub);
30 bool isInheritedSet(ast::
Decl const* decl) {
31 return methodInheritanceMap_.find(decl) != methodInheritanceMap_.end();
34 auto& getInheritedMethods(ast::
Decl const* decl) {
35 assert(isInheritedSet(decl));
37 return methodInheritanceMap_.at(decl);
40 auto& getInheritedMembers(ast::
Decl const* decl) {
42 return memberInheritancesMap_[decl];
45 void setInheritedMethods(
46 ast::
Decl const* decl,
47 std::pmr::vector<ast::MethodDecl
const*>& inheritedMethods) {
48 assert(inheritanceMap_.find(decl) != inheritanceMap_.end());
49 methodInheritanceMap_.insert({decl, inheritedMethods});
54 ast::LinkingUnit
const* lu_;
55 std::pmr::map<ast::Decl
const*, std::pmr::set<ast::Decl
const*>>
57 std::pmr::map<ast::Decl
const*, std::pmr::vector<ast::MethodDecl
const*>>
58 methodInheritanceMap_;
59 std::pmr::map<ast::Decl
const*, std::pmr::set<ast::TypedDecl
const*>>
60 memberInheritancesMap_;
61 void checkInheritance();
64 void checkClassConstructors(ast::ClassDecl
const* classDecl);
65 void checkClassMethod(
66 ast::ClassDecl
const* classDecl,
67 std::pmr::vector<ast::MethodDecl
const*>& inheritedMethods);
68 void checkInterfaceMethod(
69 ast::InterfaceDecl
const* interfaceDecl,
70 std::pmr::vector<ast::MethodDecl
const*>& inheritedMethods);
73 void checkMethodInheritance();
74 void checkMethodInheritanceHelper(ast::
Decl const* node,
75 std::pmr::set<ast::Decl
const*>& visited);
77 void setInheritedMembersHelper(ast::
Decl const* node, ast::
Decl const* parent);