Code review comment: Since we are iterating the original member type list we wont me missing any types

Code under review:
private BType getExpectedTypeForInferredTypedescMember(BUnionType originalType, BType expType, BType member) {
        if (expType == null || !this.isInvocation || !Symbols.isFlagOn(member.flags, Flags.PARAMETERIZED)) {
            return null;
        }

        BType impliedExpType = Types.getImpliedType(expType);
        if (impliedExpType.tag != TypeTags.UNION) {
            return expType;
        }

        BUnionType expUnionType = (BUnionType) impliedExpType;
        LinkedHashSet<BType> types = new LinkedHashSet<>();
        for (BType expMemType : expUnionType.getMemberTypes()) {
            boolean hasMatchWithOtherType = false;
            for (BType origMemType : originalType.getMemberTypes()) {
                if (origMemType == member) {
                    continue;
                }

                if (hasSameBasicType(expMemType, origMemType)) {
                    hasMatchWithOtherType = true;
                    break;
                }
            }

            if (!hasMatchWithOtherType) {
                types.add(expMemType);
            }
        }

        if (types.isEmpty()) {
            return null;
        }

        
        LinkedHashSet<BType> originalTypesSet = new LinkedHashSet<>(); 
        for (BType originalMemberType : expUnionType.getOriginalMemberTypes()) {
            LinkedHashSet<BType> flatTypeSet = toFlatTypeSet(new LinkedHashSet<>(Set.of(originalMemberType)));
            Set<BType> typesToAdd = flatTypeSet.stream().filter(types::contains).collect(Collectors.toSet());
            if (typesToAdd.containsAll(flatTypeSet)) {
                originalTypesSet.add(originalMemberType);
            } else {
                originalTypesSet.addAll(typesToAdd);
            }
        }

        if (originalTypesSet.size() == 1) {
            return originalTypesSet.iterator().next();
        }

        return BUnionType.create(null, originalTypesSet);
    }

Line commented on: originalTypesSet.addAll(typesToAdd);

Revised code:
private BType getExpectedTypeForInferredTypedescMember(BUnionType originalType, BType expType, BType member) {
        if (expType == null || !this.isInvocation || !Symbols.isFlagOn(member.flags, Flags.PARAMETERIZED)) {
            return null;
        }

        BType impliedExpType = Types.getImpliedType(expType);
        if (impliedExpType.tag != TypeTags.UNION) {
            return expType;
        }

        BUnionType expUnionType = (BUnionType) impliedExpType;
        LinkedHashSet<BType> types = new LinkedHashSet<>();
        for (BType expMemType : expUnionType.getMemberTypes()) {
            boolean hasMatchWithOtherType = false;
            for (BType origMemType : originalType.getMemberTypes()) {
                if (origMemType == member) {
                    continue;
                }

                if (hasSameBasicType(expMemType, origMemType)) {
                    hasMatchWithOtherType = true;
                    break;
                }
            }

            if (!hasMatchWithOtherType) {
                types.add(expMemType);
            }
        }

        if (types.isEmpty()) {
            return null;
        }

        
        LinkedHashSet<BType> originalTypesSet = new LinkedHashSet<>(); 
        for (BType originalMemberType : expUnionType.getOriginalMemberTypes()) {
            LinkedHashSet<BType> flatTypeSet = toFlatTypeSet(new LinkedHashSet<>(Set.of(originalMemberType)));
            Set<BType> typesToAdd = flatTypeSet.stream().filter(types::contains).collect(Collectors.toSet());
            if (typesToAdd.containsAll(flatTypeSet)) {
                originalTypesSet.add(originalMemberType);
            } else {
                originalTypesSet.addAll(typesToAdd);
            }
        }

        if (originalTypesSet.size() == 1) {
            return originalTypesSet.iterator().next();
        }

        return BUnionType.create(null, originalTypesSet);
    }