From 6d44c5e7d57dd270d06ecf81d6aed3111b4be406 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 6 Jul 2016 19:24:09 +1000 Subject: HIR Typecheck CS - Don't expand associated unless needed when compacting --- src/hir_typeck/helpers.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/hir_typeck/helpers.cpp b/src/hir_typeck/helpers.cpp index 0d541808..67f6445a 100644 --- a/src/hir_typeck/helpers.cpp +++ b/src/hir_typeck/helpers.cpp @@ -886,9 +886,13 @@ void TraitResolution::compact_ivars(HMTypeInferrence& m_ivars) for(auto& v : m_ivars.m_ivars) { if( !v.is_alias() ) { - auto nt = this->expand_associated_types(Span(), v.type->clone()); - DEBUG("- " << i << " " << *v.type << " -> " << nt); - *v.type = mv$(nt); + // Don't expand unless it is needed + if( this->has_associated_type(*v.type) ) { + // TODO: cloning is expensive, BUT printing below is nice + auto nt = this->expand_associated_types(Span(), v.type->clone()); + DEBUG("- " << i << " " << *v.type << " -> " << nt); + *v.type = mv$(nt); + } } else { -- cgit v1.2.3