summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/hir_typeck/helpers.cpp10
1 files changed, 7 insertions, 3 deletions
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 {