diff options
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() ) { |