From 423327162381b78599ffee6d200198665deaff26 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 25 Sep 2016 13:30:22 +0800 Subject: Resolve Use - Visit code blocks in trait defaults --- src/resolve/use.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 6f2db9d8..09c1cee9 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -145,7 +145,7 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path Resolve_Use_Mod(crate, i.data.as_Module(), path + i.name); } } - // - Handle anon modules by iterating code (allowing correct item mappings) + // - NOTE: Handle anon modules by iterating code (allowing correct item mappings) struct NV: public AST::NodeVisitorDef @@ -173,12 +173,34 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path } } expr_iter(crate, mod); - // TODO: Check that all code blocks are covered by these two + // TODO: Check that all code blocks are covered by these for(auto& i : mod.items()) { TU_MATCH_DEF( AST::Item, (i.data), (e), ( ), + (Trait, + for(auto& ti : e.items()) + { + TU_MATCH_DEF( AST::Item, (ti.data), (e), + ( + BUG(Span(), "Unexpected item in trait - " << ti.data.tag_str()); + ), + (Type, + ), + (Function, + if(e.code().is_valid()) { + e.code().node().visit( expr_iter ); + } + ), + (Static, + if( e.value().is_valid() ) { + e.value().node().visit( expr_iter ); + } + ) + ) + } + ), (Function, if( e.code().is_valid() ) { e.code().node().visit( expr_iter ); -- cgit v1.2.3