diff --git a/src/qir/types/QIRRecordType.java b/src/qir/types/QIRRecordType.java index 809ebce73bf132588126b1bc680713e3e3aa777b..76bc6e5087b94149f252afc7a722a2e28c306aa3 100644 --- a/src/qir/types/QIRRecordType.java +++ b/src/qir/types/QIRRecordType.java @@ -41,7 +41,7 @@ public class QIRRecordType extends QIRType { return fieldTypes.get(id); } - public final boolean unionWith(final QIRRecordType other) { + public final boolean union(final QIRRecordType other) { for (Entry<String, QIRType> otherEntry : other.fieldTypes.entrySet()) { final String otherKey = otherEntry.getKey(); final QIRType otherValue = otherEntry.getValue(); @@ -61,7 +61,7 @@ public class QIRRecordType extends QIRType { final QIRRecordType res = new QIRRecordType(new HashMap<>()); for (int i = 0; i < records.length; i++) - res.unionWith(records[i]); + res.union(records[i]); return res; } diff --git a/src/qir/types/QIRSomeType.java b/src/qir/types/QIRSomeType.java index 99eb00f2f01c801ca6e86bc9ff493ed9133221fc..c103839071e494565f54182593302fe26b399779 100644 --- a/src/qir/types/QIRSomeType.java +++ b/src/qir/types/QIRSomeType.java @@ -24,20 +24,15 @@ public class QIRSomeType extends QIRType { @Override protected boolean isSubtypeOfSpecific(final QIRType other) { if (other instanceof QIRRecordType) { - if (infered.isPresent()) { - if (infered.get() instanceof QIRRecordType) { - ((QIRRecordType) infered.get()).unionWith((QIRRecordType) other); - return true; - } else - return false; - } + if (infered.isPresent()) + return infered.get() instanceof QIRRecordType && ((QIRRecordType) infered.get()).union((QIRRecordType) other); infered = Optional.of(other); return true; } if (!infered.isPresent() || other.isSubtypeOf(infered.get())) { if (other instanceof QIRSomeType) { if (((QIRSomeType) other).infered.isPresent()) - infered = Optional.of(((QIRSomeType) other).infered.get()); + infered = ((QIRSomeType) other).infered; } else infered = Optional.of(other); return true;