Skip to content
Snippets Groups Projects
Commit e02f6a57 authored by Julien Lopez's avatar Julien Lopez
Browse files

Fix in subtype for QIRSomeType

parent be463ac1
No related branches found
No related tags found
No related merge requests found
Pipeline #710 failed
......@@ -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;
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment