diff options
Diffstat (limited to 'src/convert')
-rw-r--r-- | src/convert/ast_iterate.cpp | 3 | ||||
-rw-r--r-- | src/convert/typecheck_expr.cpp | 4 | ||||
-rw-r--r-- | src/convert/typecheck_params.cpp | 15 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/convert/ast_iterate.cpp b/src/convert/ast_iterate.cpp index c6293393..a80b1f7f 100644 --- a/src/convert/ast_iterate.cpp +++ b/src/convert/ast_iterate.cpp @@ -287,7 +287,8 @@ void CASTIterator::handle_impl(AST::Path modpath, AST::Impl& impl) handle_params( impl.params() ); // Trait - handle_type( impl.trait() ); + if( impl.trait() != AST::Path() ) + handle_path( impl.trait(), MODE_TYPE ); // Type handle_type( impl.type() ); diff --git a/src/convert/typecheck_expr.cpp b/src/convert/typecheck_expr.cpp index 57678e94..4fb7f174 100644 --- a/src/convert/typecheck_expr.cpp +++ b/src/convert/typecheck_expr.cpp @@ -503,7 +503,7 @@ void CTC_NodeVisitor::visit(AST::ExprNode_CallMethod& node) else { // 2. Find inherent impl - auto oimpl = m_tc.m_crate.find_impl(TypeRef(), ltype); + auto oimpl = m_tc.m_crate.find_impl(AST::Path(), ltype); if( oimpl.is_some() ) { AST::Impl& impl = oimpl.unwrap(); @@ -522,7 +522,7 @@ void CTC_NodeVisitor::visit(AST::ExprNode_CallMethod& node) // 2. Iterate in-scope traits m_tc.iterate_traits( [&](const TypeRef& trait) { // TODO: Check trait first, then find an impl - auto oimpl = m_tc.m_crate.find_impl(trait, ltype); + auto oimpl = m_tc.m_crate.find_impl(trait.path(), ltype); if( oimpl.is_some() ) { AST::Impl& impl = oimpl.unwrap(); diff --git a/src/convert/typecheck_params.cpp b/src/convert/typecheck_params.cpp index 28c4e72a..2e4bc97c 100644 --- a/src/convert/typecheck_params.cpp +++ b/src/convert/typecheck_params.cpp @@ -30,7 +30,14 @@ class CGenericParamChecker: }; // name == "" indicates edge of a scope ::std::vector<LocalType> m_types_stack; + + AST::Crate& m_crate; public: + CGenericParamChecker(AST::Crate& c): + m_crate(c) + { + } + virtual void handle_path(AST::Path& path, CASTIterator::PathMode pm) override; virtual void handle_expr(AST::ExprNode& root) override; void start_scope() override; @@ -114,6 +121,12 @@ bool CGenericParamChecker::has_impl(const TypeRef& type, const AST::Path& trait) else { // Search all known impls of this trait (TODO: keep a list at the crate level) for a match to this type + auto i = m_crate.find_impl(trait, trait); + if( i.is_none() ) { + DEBUG("- Nope"); + return false; + } + throw CompileError::Todo( FMT("Search for impls on " << type << " for trait " << trait) ); } @@ -299,7 +312,7 @@ const CGenericParamChecker::LocalType* CGenericParamChecker::find_type_by_name(c void Typecheck_GenericParams(AST::Crate& crate) { DEBUG(" >>> "); - CGenericParamChecker chk; + CGenericParamChecker chk(crate); chk.handle_module(AST::Path({}), crate.root_module()); DEBUG(" <<< "); } |