From e10c279836b0f5edac588a90dc1c42177bb7c48d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 5 Oct 2016 11:33:52 +0800 Subject: Resolve+Typecheck - Fix trait default parameters --- src/resolve/absolute.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/resolve/absolute.cpp') diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index ee5d6b36..1c725718 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -818,6 +818,13 @@ namespace { if( !n.args().is_empty() ) { trait_path.nodes().back().args() = mv$(n.args()); } + else { + for(const auto& typ : e.m_params.m_types) + { + (void)typ; + trait_path.nodes().back().args().m_types.push_back( ::TypeRef() ); + } + } trait_path.bind( ::AST::PathBinding::make_Trait({nullptr, &e}) ); ::AST::Path new_path; @@ -1077,6 +1084,22 @@ void Resolve_Absolute_Path_BindAbsolute(Context& context, const Span& sp, Contex if( !n.args().is_empty() ) { trait_path.nodes().back().args() = mv$(n.args()); } + else { + if( e.trait_ ) { + for(const auto& typ : e.trait_->params().ty_params()) + { + (void)typ; + trait_path.nodes().back().args().m_types.push_back( ::TypeRef() ); + } + } + else { + for(const auto& typ : e.hir->m_params.m_types) + { + (void)typ; + trait_path.nodes().back().args().m_types.push_back( ::TypeRef() ); + } + } + } // TODO: If the named item can't be found in the trait, fall back to it being a type binding // - What if this item is from a nested trait? ::AST::Path new_path; -- cgit v1.2.3