diff options
-rw-r--r-- | src/mir/from_hir_match.cpp | 14 | ||||
-rw-r--r-- | src/mir/mir_builder.cpp | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index 49861187..d7dcc354 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -1098,7 +1098,7 @@ void PatternRulesetBuilder::append_from(const Span& sp, const ::HIR::Pattern& pa namespace { void get_ty_and_val( - const Span& sp, + const Span& sp, const StaticTraitResolve& resolve, const ::HIR::TypeRef& top_ty, const ::MIR::LValue& top_val, const field_path_t& field_path, unsigned int field_path_ofs, /*Out ->*/ ::HIR::TypeRef& out_ty, ::MIR::LValue& out_val @@ -1135,7 +1135,11 @@ namespace { ), (Struct, // TODO: Should this do a call to expand_associated_types? - auto monomorph = [&](const auto& ty) { return monomorphise_type(sp, pbe->m_params, e.path.m_data.as_Generic().m_params, ty); }; + auto monomorph = [&](const auto& ty) { + auto rv = monomorphise_type(sp, pbe->m_params, e.path.m_data.as_Generic().m_params, ty); + resolve.expand_associated_types(sp, rv); + return rv; + }; TU_MATCHA( (pbe->m_data), (fields), (Unit, BUG(sp, "Destructuring an unit-like tuple - " << *cur_ty); @@ -1296,7 +1300,7 @@ int MIR_LowerHIR_Match_Simple__GeneratePattern(MirBuilder& builder, const Span& ::MIR::LValue val; ::HIR::TypeRef ity; - get_ty_and_val(sp, top_ty, top_val, rule.field_path, field_path_ofs, ity, val); + get_ty_and_val(sp, builder.resolve(), top_ty, top_val, rule.field_path, field_path_ofs, ity, val); DEBUG("ty = " << ity << ", val = " << val); const auto& ty = ity; @@ -2872,7 +2876,7 @@ void DecisionTreeGen::generate_tree_code( ::MIR::LValue val; ::HIR::TypeRef ty; - get_ty_and_val(sp, top_ty, top_val, node.m_field_path, field_path_ofs, ty, val); + get_ty_and_val(sp, m_builder.resolve(), top_ty, top_val, node.m_field_path, field_path_ofs, ty, val); DEBUG("ty = " << ty << ", val = " << val); TU_MATCHA( (ty.m_data), (e), @@ -3347,6 +3351,7 @@ void DecisionTreeGen::generate_branches_Enum( ents.push_back( monomorphise_type(sp, enum_ref.m_params, enum_path.m_params, fld.ent) ); } fake_ty = ::HIR::TypeRef( mv$(ents) ); + m_builder.resolve().expand_associated_types(sp, fake_ty); DEBUG("- Tuple - " << fake_ty); ), (Struct, @@ -3356,6 +3361,7 @@ void DecisionTreeGen::generate_branches_Enum( ents.push_back( monomorphise_type(sp, enum_ref.m_params, enum_path.m_params, fld.second.ent) ); } fake_ty = ::HIR::TypeRef( mv$(ents) ); + m_builder.resolve().expand_associated_types(sp, fake_ty); DEBUG("- Struct - " << fake_ty); ) ) diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index 1148aec2..a64867b1 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -815,7 +815,7 @@ void MirBuilder::with_val_type(const Span& sp, const ::MIR::LValue& val, ::std:: BUG(sp, "Downcast on unexpected type - " << ty); ), (Path, - ASSERT_BUG(sp, !te.binding.is_Unbound(), "Unbound path " << ty << " encountered"); + //ASSERT_BUG(sp, !te.binding.is_Unbound(), "Unbound path " << ty << " encountered"); ASSERT_BUG(sp, te.binding.is_Enum(), "Downcast on non-Enum - " << ty << " for " << val); const auto& enm = *te.binding.as_Enum(); const auto& variants = enm.m_variants; @@ -833,6 +833,7 @@ void MirBuilder::with_val_type(const Span& sp, const ::MIR::LValue& val, ::std:: for(const auto& fld : ve) tys.push_back( monomorphise_type(sp, enm.m_params, te.path.m_data.as_Generic().m_params, fld.ent) ); ::HIR::TypeRef tup( mv$(tys) ); + m_resolve.expand_associated_types(sp, tup); cb(tup); ), (Struct, @@ -841,6 +842,7 @@ void MirBuilder::with_val_type(const Span& sp, const ::MIR::LValue& val, ::std:: for(const auto& fld : ve) tys.push_back( monomorphise_type(sp, enm.m_params, te.path.m_data.as_Generic().m_params, fld.second.ent) ); ::HIR::TypeRef tup( mv$(tys) ); + m_resolve.expand_associated_types(sp, tup); cb(tup); ) ) |