mirror of
				https://github.com/DanilaFe/abacus
				synced 2025-11-03 18:33:41 -08:00 
			
		
		
		
	Merge pull request #33 from DanilaFe/promotion-fix
Fix a bug that made some same-priority implementations not convert.
This commit is contained in:
		
						commit
						566598b702
					
				@ -18,7 +18,7 @@ public class PromotionException extends AbacusException {
 | 
				
			|||||||
     * @param message the additional message to include with the error.
 | 
					     * @param message the additional message to include with the error.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public PromotionException(String message) {
 | 
					    public PromotionException(String message) {
 | 
				
			||||||
        super("Failed to promote number instances.", message);
 | 
					        super("Failed to promote number instances", message);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -59,14 +59,12 @@ class PromotionManager(val abacus: Abacus) : PluginListener {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    override fun onLoad(manager: PluginManager) {
 | 
					    override fun onLoad(manager: PluginManager) {
 | 
				
			||||||
        val implementations = manager.allNumberImplementations.map { manager.numberImplementationFor(it) }
 | 
					        val implementations = manager.allNumberImplementations.map { manager.numberImplementationFor(it) }
 | 
				
			||||||
        for((index, value) in implementations.withIndex()){
 | 
					        for(first in implementations) {
 | 
				
			||||||
            for(i in index until implementations.size){
 | 
					            for(second in implementations) {
 | 
				
			||||||
                val other = implementations[i]
 | 
					                val promoteFrom = if(second.priority > first.priority) first else second
 | 
				
			||||||
 | 
					                val promoteTo = if(second.priority > first.priority) second else first
 | 
				
			||||||
                val promoteFrom = if(other.priority > value.priority) value else other
 | 
					 | 
				
			||||||
                val promoteTo = if(other.priority > value.priority) other else value
 | 
					 | 
				
			||||||
                val path = computePathBetween(promoteFrom, promoteTo)
 | 
					                val path = computePathBetween(promoteFrom, promoteTo)
 | 
				
			||||||
                computePaths.put(promoteFrom to promoteTo, path)
 | 
					                computePaths[promoteFrom to promoteTo] = path
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user