diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-12 09:38:30 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-12 09:38:30 +0800 |
commit | d1b9ffeed07a3b8846b79a6ba6247b8c320efaf0 (patch) | |
tree | 6ac2c4ba1aba2799dc31fcc08d6381e34680d05d /src/resolve/absolute.cpp | |
parent | 058047f175ba166764a77956542bec786d59d21a (diff) | |
download | mrust-d1b9ffeed07a3b8846b79a6ba6247b8c320efaf0.tar.gz |
Resolve Absolute - Split multi-node UFCS
Diffstat (limited to 'src/resolve/absolute.cpp')
-rw-r--r-- | src/resolve/absolute.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index 874664dd..133840fd 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -528,13 +528,20 @@ void Resolve_Absolute_PathNodes(/*const*/ Context& context, const Span& sp, ::st void Resolve_Absolute_Path_BindUFCS(Context& context, const Span& sp, Context::LookupMode& mode, ::AST::Path& path) { - const auto& ufcs = path.m_class.as_UFCS(); - - if( ufcs.nodes.size() > 1 ) + while( path.m_class.as_UFCS().nodes.size() > 1 ) { // More than one node, break into inner UFCS - TODO(sp, "Split multi-node UFCS - " << path); + // - Since traits can't be associated items, this will always be the same form + + auto span = path.m_class.as_UFCS().type->span(); + auto nodes = mv$(path.m_class.as_UFCS().nodes); + auto inner_path = mv$(path); + inner_path.m_class.as_UFCS().nodes.push_back( mv$(nodes.front()) ); + nodes.erase( nodes.begin() ); + path = ::AST::Path( ::AST::Path::TagUfcs(), TypeRef(span, mv$(inner_path)), mv$(nodes) ); } + + const auto& ufcs = path.m_class.as_UFCS(); if( ufcs.nodes.size() == 0 ) { if( mode == Context::LookupMode::Type && ufcs.trait && *ufcs.trait == ::AST::Path() ) { |