From d545aa5cdfb6813c0b4f77a6b66e391a3d887fb4 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 31 Aug 2017 16:19:00 +0800 Subject: HIR - Fix minor bug in specialisation ordering --- src/hir/hir.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index e3f78102..a8cffda2 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -558,15 +558,16 @@ bool ::HIR::TraitImpl::more_specific_than(const ::HIR::TraitImpl& other) const try { auto ord = type_ord_specific(sp, this->m_type, other.m_type); + // If `*this` < `other` : false if( ord != ::OrdEqual ) { - DEBUG("- Type " << (ord == ::OrdLess ? "less" : "more") << " specific - " << this->m_type << " AND " << other.m_type); - return ord == ::OrdLess; + DEBUG("- Type " << this->m_type << " " << (ord == ::OrdLess ? "less" : "more") << " specific than " << other.m_type); + return ord == ::OrdGreater; } // 2. If any in te.impl->m_params is less specific than oe.impl->m_params: return false ord = typelist_ord_specific(sp, this->m_trait_args.m_types, other.m_trait_args.m_types); if( ord != ::OrdEqual ) { DEBUG("- Trait arguments " << (ord == ::OrdLess ? "less" : "more") << " specific"); - return ord == ::OrdLess; + return ord == ::OrdGreater; } } catch(const TypeOrdSpecific_MixedOrdering& e) -- cgit v1.2.3