1
0
mirror of https://github.com/DanilaFe/abacus synced 2026-01-25 08:05:19 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
eb91a5b875 Fix a bug that made some same-priority implementations not convert. 2017-09-20 12:47:30 -07:00
fcd4694203 Merge pull request #32 from DanilaFe/promotion-exception
Add an exception thrown when promotion fails.
2017-09-20 12:16:00 -07:00
2 changed files with 6 additions and 8 deletions

View File

@@ -18,7 +18,7 @@ public class PromotionException extends AbacusException {
* @param message the additional message to include with the error.
*/
public PromotionException(String message) {
super("Failed to promote number instances.", message);
super("Failed to promote number instances", message);
}
}

View File

@@ -59,14 +59,12 @@ class PromotionManager(val abacus: Abacus) : PluginListener {
override fun onLoad(manager: PluginManager) {
val implementations = manager.allNumberImplementations.map { manager.numberImplementationFor(it) }
for((index, value) in implementations.withIndex()){
for(i in index until implementations.size){
val other = implementations[i]
val promoteFrom = if(other.priority > value.priority) value else other
val promoteTo = if(other.priority > value.priority) other else value
for(first in implementations) {
for(second in implementations) {
val promoteFrom = if(second.priority > first.priority) first else second
val promoteTo = if(second.priority > first.priority) second else first
val path = computePathBetween(promoteFrom, promoteTo)
computePaths.put(promoteFrom to promoteTo, path)
computePaths[promoteFrom to promoteTo] = path
}
}
}