summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hir_conv/expand_type.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/hir_conv/expand_type.cpp b/src/hir_conv/expand_type.cpp
index 76349ff8..ff00743d 100644
--- a/src/hir_conv/expand_type.cpp
+++ b/src/hir_conv/expand_type.cpp
@@ -5,6 +5,7 @@
#include <hir/hir.hpp>
#include <hir/expr.hpp>
#include <hir/visitor.hpp>
+#include <hir_typeck/common.hpp> // monomorphise_type_with
::HIR::TypeRef ConvertHIR_ExpandAliases_GetExpansion(const ::HIR::Crate& crate, const ::HIR::Path& path)
{
@@ -17,10 +18,29 @@
// Anything else - leave it be
),
(TypeAlias,
+ if( e.m_params.m_types.size() != e2.m_params.m_types.size() ) {
+ ERROR(sp, E0000, "Mismatched parameter count in " << path);
+ }
if( e2.m_params.m_types.size() > 0 ) {
- TODO(Span(), "Replace type params in type alias");
+ // TODO: Better `monomorphise_type`
+ return monomorphise_type_with(sp, e2.m_type, [&](const auto& gt)->const auto& {
+ const auto& ge = gt.m_data.as_Generic();
+ if( ge.binding == 0xFFFF ) {
+ BUG(sp, "Self encountered in expansion for " << path << " - " << e2.m_type);
+ }
+ else if( (ge.binding >> 8) == 0 ) {
+ auto idx = ge.binding & 0xFF;
+ ASSERT_BUG(sp, idx < e.m_params.m_types.size(), "");
+ return e.m_params.m_types[idx];
+ }
+ else {
+ BUG(sp, "Bad index " << ge.binding << " encountered in expansion for " << path << " - " << e2.m_type);
+ }
+ });
+ }
+ else {
+ return e2.m_type.clone();
}
- return e2.m_type.clone();
)
)
),