diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-01-05 10:52:48 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-01-05 10:52:48 +0800 |
commit | c0267e165eca49583ac6ba7c3b48ba68ec4eee49 (patch) | |
tree | 517330f763212e5e19c8aadebf9999b5a6a04418 /src | |
parent | 611ea37948b415fba9c9f97bb14f8d279ca2eef3 (diff) | |
download | mrust-c0267e165eca49583ac6ba7c3b48ba68ec4eee49.tar.gz |
HIR Bind - Handle cross-referencing default type params
Diffstat (limited to 'src')
-rw-r--r-- | src/hir_conv/bind.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/hir_conv/bind.cpp b/src/hir_conv/bind.cpp index 37a6e494..9d15da18 100644 --- a/src/hir_conv/bind.cpp +++ b/src/hir_conv/bind.cpp @@ -317,6 +317,8 @@ namespace { return ; } + TRACE_FUNCTION_F(path); + if( params.m_types.size() == 0 && fill_infer ) { for(const auto& typ : param_defs.m_types) { (void)typ; @@ -337,9 +339,20 @@ namespace { auto ty = clone_ty_with(sp, typ.m_default, [&](const auto& ty, auto& out){ if(const auto* te = ty.m_data.opt_Generic() ) { - if( te->binding != GENERIC_Self || !self_ty ) + if( te->binding == GENERIC_Self ) { + if( !self_ty ) + TODO(sp, "Self enountered in default params, but no Self available - " << ty << " in " << typ.m_default << " for " << path); + out = self_ty->clone(); + } + // NOTE: Should only be seeing impl-level params here. Method-level ones are only seen in expression context. + else if( (te->binding >> 8) == 0 ) { + auto idx = te->binding & 0xFF; + ASSERT_BUG(sp, idx < params.m_types.size(), "TODO: Handle use of latter types in defaults"); + out = params.m_types[idx].clone(); + } + else { TODO(sp, "Monomorphise in fix_param_count - encountered " << ty << " in " << typ.m_default); - out = self_ty->clone(); + } return true; } return false; |