ConversionResult (@NotNull PsiType lType, @NotNull PsiType rType, @NotNull Position position, @NotNull GroovyPsiElement context) { if (!PsiTypes.charType().equals(TypesUtil.unboxPrimitiveTypeWrapper(lType))) return null; if (PsiTypes.charType().equals(TypesUtil.unboxPrimitiveTypeWrapper(rType))) return ConversionResult.OK; // can assign numeric types to char if (TypesUtil.isNumericType(rType)) { if (rType instanceof PsiPrimitiveType || TypesUtil.unboxPrimitiveTypeWrapper(rType) instanceof PsiPrimitiveType) { return PsiTypes.charType().equals(lType) ? ConversionResult.OK : ConversionResult.ERROR; } else { // BigDecimal && BigInteger return ConversionResult.ERROR; } } { // special case 'c = []' will throw RuntimeError final GrExpression rValue; if (context instanceof GrAssignmentExpression) { final GrAssignmentExpression assignmentExpression = (GrAssignmentExpression)context; rValue = assignmentExpression.getRValue(); } else if (context instanceof GrVariable) { final GrVariable assignmentExpression = (GrVariable)context; rValue = assignmentExpression.getInitializerGroovy(); } else { rValue = null; } if (rValue instanceof GrListOrMap && ((GrListOrMap)rValue).isEmpty()) { return ConversionResult.WARNING; } } if (PsiTypes.booleanType().equals(TypesUtil.unboxPrimitiveTypeWrapper(rType))) { return switch (position) { case ASSIGNMENT, RETURN_VALUE -> ConversionResult.WARNING; default -> null; }; } // one-symbol string-to-char conversion doesn't work with return value if (position == Position.RETURN_VALUE) { return null; } // can cast and assign one-symbol strings to char if (!TypesUtil.isClassType(rType, CommonClassNames.JAVA_LANG_STRING)) return null; return checkSingleSymbolLiteral(context) ? ConversionResult.OK : ConversionResult.ERROR; }