{"record":{"id":"25347e8b9e56ecd0","repo":"permissions-dispatcher/PermissionsDispatcher","slug":"method-e-simplestring-must-specify-return","errorCode":null,"errorMessage":"Method '${e.simpleString()}()' must specify return type 'void', not '${e.returnType}'","messagePattern":"Method '(.+?)\\(\\)' must specify return type 'void', not '(.+?)'","errorType":"validation","errorClass":"WrongReturnTypeException","httpStatus":null,"severity":"error","filePath":"processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt","lineNumber":82,"sourceCode":" */\nfun <A : Annotation> checkPrivateMethods(items: List<ExecutableElement>, annotationClass: Class<A>) {\n    items.forEach {\n        if (it.modifiers.contains(Modifier.PRIVATE)) {\n            throw PrivateMethodException(it, annotationClass)\n        }\n    }\n}\n\n/**\n * Checks the return type of the elements in the provided list.\n * <p>\n * Raises an exception if any element specifies a return type other than 'void'.\n */\nfun checkMethodSignature(items: List<ExecutableElement>) {\n    items.forEach {\n        // Allow 'void' return type only\n        if (it.returnType.kind != TypeKind.VOID) {\n            throw WrongReturnTypeException(it)\n        }\n        // Allow methods without 'throws' declaration only\n        if (it.thrownTypes.isNotEmpty()) {\n            throw NoThrowsAllowedException(it)\n        }\n    }\n}\n\nfun checkMethodParameters(items: List<ExecutableElement>, numParams: Int, requiredType: TypeMirror? = null) {\n    items.forEach {\n        val params = it.parameters\n        if (numParams == 0 && params.isNotEmpty()) {\n            throw NoParametersAllowedException(it)\n        }\n        if (requiredType == null) {\n            return\n        }\n        if (numParams < params.size) {","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/74b532bf1fe430fb12ad8414b80399f2d7cfc954/processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt#L64-L100","documentation":"Thrown by checkMethodSignature in Validators.kt:82 via WrongReturnTypeException. Methods annotated with @NeedsPermission or related annotations must return void (Unit in Kotlin); the generated dispatcher relies on a fire-and-forget signature and cannot handle return values.","triggerScenarios":"Annotated method returning a non-void type, e.g. fun showCamera(): Boolean or fun getCamera() : Camera annotated with @NeedsPermission.","commonSituations":"Converting an existing getter-like method into a permission-gated one; adding the annotation to a method that returns a status/result; Java methods returning boolean/int annotated for convenience.","solutions":["Change the return type to void (Unit in Kotlin) and store any needed result in a field or via callback.","Move the annotation to a separate void method that performs the action.","If a result is required, compute it inside the void method and pass it to a listener/callback."],"exampleFix":"// before\n@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera(): Boolean { ... }\n\n// after\n@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { ... }","handlingStrategy":"validation","validationCode":"@NeedsPermission(Manifest.permission.CAMERA)\nfun showCamera() { /* Unit return */ }","typeGuard":null,"tryCatchPattern":"try {\n    build()\n} catch (e: CompilationError) {\n    logger.error(\"Permission methods must return void/Unit\", e)\n}","preventionTips":["Annotate only void/Unit methods.","Return results via fields or callbacks, not return values.","Check signature after refactoring return types."],"tags":["kotlin","annotation-processor","return-type"],"backgroundTag":"type-mismatch","analyzedSha":"74b532bf1fe430fb12ad8414b80399f2d7cfc954","analyzedAt":"2026-09-08T21:44:58.380Z","contentChangedAt":"2026-09-08T21:44:58.380Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}