}
final Map<FieldName, TypeExpr> allFieldsMap = new HashMap<FieldName, TypeExpr>(); //map containing all the context fields and fields added with the value editor, RecordFieldName -> TypeExpr
for (int i = 0; i < numFields; i++) {
final FieldName fieldName = hasFieldNames.get(i);
if (contextFieldsMap.containsKey(fieldName)) {
allFieldsMap.put(fieldName, contextFieldsMap.get(fieldName));
} else {
allFieldsMap.put(fieldName, TypeExpr.makeParametricType());
}
}
final RecordType leastConstrainedRecordType = TypeExpr.makePolymorphicRecordType(allFieldsMap);
// add the record node itself to the result map
resultMap.put(currentValueNode, leastConstrainedRecordType);
// add all the record field nodes to the result map
for (int j = 0; j < numFields; j++) {
ValueNode currentFieldNode = currentValueNode.getValueAt(j);
FieldName fieldName = hasFieldNames.get(j);
TypeExpr leastConstrainedRecordElementType = leastConstrainedRecordType.getHasFieldType(fieldName);
resultMap.put(currentFieldNode, leastConstrainedRecordElementType);
}