Code review comment: I think it's okay to use the `data.expType` here instead of the actual type, since it's the expected type of the expression.

Code under review:
private void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, AnalyzerData data) {
        String operatorType = checkedExpr.getKind() == NodeKind.CHECK_EXPR ? "check" : "checkpanic";
        BLangExpression exprWithCheckingKeyword = checkedExpr.expr;
        boolean firstVisit = exprWithCheckingKeyword.getBType() == null;

        BType checkExprCandidateType;
        if (data.expType == symTable.noType) {
            checkExprCandidateType = symTable.noType;
        } else {
            BType exprType = getCandidateType(checkedExpr, data.expType, data);
            if (exprType == symTable.semanticError) {
                checkExprCandidateType = BUnionType.create(null, data.expType, symTable.errorType);
            } else {
                checkExprCandidateType = addDefaultErrorIfNoErrorComponentFound(data.expType);
            }
        }

        if (checkedExpr.getKind() == NodeKind.CHECK_EXPR && types.isUnionOfSimpleBasicTypes(data.expType)) {
            rewriteWithEnsureTypeFunc(checkedExpr, checkExprCandidateType, data);
        }

        BType exprType = checkExpr(checkedExpr.expr, checkExprCandidateType, data);
        if (checkedExpr.expr.getKind() == NodeKind.WORKER_RECEIVE) {
            if (firstVisit) {
                data.isTypeChecked = false;
                data.resultType = data.expType;
                return;
            } else {
                data.expType = checkedExpr.getBType();
                exprType = checkedExpr.expr.getBType();
            }
        }

        boolean isErrorType = types.isAssignable(Types.getReferredType(exprType), symTable.errorType);
        if (Types.getReferredType(exprType).tag != TypeTags.UNION && !isErrorType) {
            if (exprType.tag == TypeTags.READONLY) {
                checkedExpr.equivalentErrorTypeList = new ArrayList<>(1) {{
                    add(symTable.errorType);
                }};
                data.resultType = symTable.anyAndReadonly;
                return;
            } else if (exprType != symTable.semanticError) {
                dlog.warning(checkedExpr.expr.pos,
                        DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS,
                        operatorType);
                data.resultType = checkedExpr.expr.getBType();

                BLangTypeConversionExpr impConversionExpr = checkedExpr.expr.impConversionExpr;
                if (impConversionExpr != null) {
                    
                    BType expType = Types.getReferredType(data.expType);
                    impConversionExpr.setBType(expType);
                    impConversionExpr.targetType = expType;
                }
            }
            checkedExpr.setBType(symTable.semanticError);
            return;
        }

        
        List<BType> errorTypes = new ArrayList<>();
        List<BType> nonErrorTypes = new ArrayList<>();
        if (!isErrorType) {
            for (BType memberType : types.getAllTypes(exprType, true)) {
                if (memberType.tag == TypeTags.READONLY) {
                    errorTypes.add(symTable.errorType);
                    nonErrorTypes.add(symTable.anyAndReadonly);
                    continue;
                }
                if (types.isAssignable(memberType, symTable.errorType)) {
                    errorTypes.add(memberType);
                    continue;
                }
                nonErrorTypes.add(memberType);
            }
        } else {
            errorTypes.add(exprType);
        }

        
        checkedExpr.equivalentErrorTypeList = errorTypes;
        if (errorTypes.isEmpty()) {
            
            dlog.warning(checkedExpr.expr.pos,
                    DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS, operatorType);
            checkedExpr.setBType(symTable.semanticError);
            return;
        }

        BType actualType;
        if (nonErrorTypes.size() == 0) {
            actualType = symTable.neverType;
        } else if (nonErrorTypes.size() == 1) {
            actualType = nonErrorTypes.get(0);
        } else {
            actualType = BUnionType.create(null, new LinkedHashSet<>(nonErrorTypes));
        }

        data.resultType = types.checkType(checkedExpr, actualType, data.expType);
    }

Line commented on: BType expType = Types.getReferredType(data.expType);

Revised code:
private void visitCheckAndCheckPanicExpr(BLangCheckedExpr checkedExpr, AnalyzerData data) {
        String operatorType = checkedExpr.getKind() == NodeKind.CHECK_EXPR ? "check" : "checkpanic";
        BLangExpression exprWithCheckingKeyword = checkedExpr.expr;
        boolean firstVisit = exprWithCheckingKeyword.getBType() == null;

        BType checkExprCandidateType;
        if (data.expType == symTable.noType) {
            checkExprCandidateType = symTable.noType;
        } else {
            BType exprType = getCandidateType(checkedExpr, data.expType, data);
            if (exprType == symTable.semanticError) {
                checkExprCandidateType = BUnionType.create(null, data.expType, symTable.errorType);
            } else {
                checkExprCandidateType = addDefaultErrorIfNoErrorComponentFound(data.expType);
            }
        }

        if (checkedExpr.getKind() == NodeKind.CHECK_EXPR && types.isUnionOfSimpleBasicTypes(data.expType)) {
            rewriteWithEnsureTypeFunc(checkedExpr, checkExprCandidateType, data);
        }

        BType exprType = checkExpr(checkedExpr.expr, checkExprCandidateType, data);
        if (checkedExpr.expr.getKind() == NodeKind.WORKER_RECEIVE) {
            if (firstVisit) {
                data.isTypeChecked = false;
                data.resultType = data.expType;
                return;
            } else {
                data.expType = checkedExpr.getBType();
                exprType = checkedExpr.expr.getBType();
            }
        }

        boolean isErrorType = types.isAssignable(Types.getReferredType(exprType), symTable.errorType);
        if (Types.getReferredType(exprType).tag != TypeTags.UNION && !isErrorType) {
            if (exprType.tag == TypeTags.READONLY) {
                checkedExpr.equivalentErrorTypeList = new ArrayList<>(1) {{
                    add(symTable.errorType);
                }};
                data.resultType = symTable.anyAndReadonly;
                return;
            } else if (exprType != symTable.semanticError) {
                dlog.warning(checkedExpr.expr.pos,
                        DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS,
                        operatorType);
                checkedExpr.isRedundantChecking = true;
                data.resultType = checkedExpr.expr.getBType();

                
                resetImpConversionExpr(checkedExpr.expr, data.resultType, data.expType);
            }
            checkedExpr.setBType(symTable.semanticError);
            return;
        }

        
        List<BType> errorTypes = new ArrayList<>();
        List<BType> nonErrorTypes = new ArrayList<>();
        if (!isErrorType) {
            for (BType memberType : types.getAllTypes(exprType, true)) {
                if (memberType.tag == TypeTags.READONLY) {
                    errorTypes.add(symTable.errorType);
                    nonErrorTypes.add(symTable.anyAndReadonly);
                    continue;
                }
                if (types.isAssignable(memberType, symTable.errorType)) {
                    errorTypes.add(memberType);
                    continue;
                }
                nonErrorTypes.add(memberType);
            }
        } else {
            errorTypes.add(exprType);
        }

        
        checkedExpr.equivalentErrorTypeList = errorTypes;
        if (errorTypes.isEmpty()) {
            
            dlog.warning(checkedExpr.expr.pos,
                    DiagnosticWarningCode.CHECKED_EXPR_INVALID_USAGE_NO_ERROR_TYPE_IN_RHS, operatorType);
            checkedExpr.isRedundantChecking = true;

            
            resetImpConversionExpr(checkedExpr.expr, data.resultType, data.expType);

            checkedExpr.setBType(symTable.semanticError);
            return;
        }

        BType actualType;
        if (nonErrorTypes.size() == 0) {
            actualType = symTable.neverType;
        } else if (nonErrorTypes.size() == 1) {
            actualType = nonErrorTypes.get(0);
        } else {
            actualType = BUnionType.create(null, new LinkedHashSet<>(nonErrorTypes));
        }

        data.resultType = types.checkType(checkedExpr, actualType, data.expType);
    }