Report unification of a logical with itself as a failure.

This commit is contained in:
Fedor Isakov 2018-12-28 11:47:46 +01:00
parent 6c0a9d404b
commit 6953939e4a
1 changed files with 4 additions and 0 deletions

View File

@ -118,6 +118,10 @@ class LogicalImpl<T> : JoinableLogical<T> {
val thisRepr = this.find()
val otherRepr = (other as LogicalImpl<T>).find()
if (thisRepr === otherRepr) {
throw IllegalStateException("cannnot unite logical with itself")
}
// invariant: thisRepr.rank > otherRepr.rank
if (thisRepr.rank() < otherRepr.rank()) {
otherRepr.union(thisRepr, reconciler);