void (@NotNull GrReturnStatement returnStatement) { final GrExpression value = returnStatement.getReturnValue(); if (value != null) { final PsiType type = value.getType(); if (type != null) { final GrParameterListOwner owner = PsiTreeUtil.getParentOfType(returnStatement, GrParameterListOwner.class); if (owner instanceof PsiMethod method) { if (method.isConstructor()) { myHolder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("cannot.return.from.constructor")).range(value).create(); } else { final PsiType methodType = method.getReturnType(); if (methodType != null) { if (PsiTypes.voidType().equals(methodType)) { myHolder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("cannot.return.from.void.method")).range(value).create(); } } } } } } }