diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-05 11:33:52 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-05 11:33:52 +0800 |
commit | e10c279836b0f5edac588a90dc1c42177bb7c48d (patch) | |
tree | 864d8b6032c355be7a770ccc497540254127366e /src/resolve/absolute.cpp | |
parent | df6b00d53966d9cf30e5ef959dbb18005f44fcbf (diff) | |
download | mrust-e10c279836b0f5edac588a90dc1c42177bb7c48d.tar.gz |
Resolve+Typecheck - Fix trait default parameters
Diffstat (limited to 'src/resolve/absolute.cpp')
-rw-r--r-- | src/resolve/absolute.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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; |