{"record":{"id":"26933e7791b8ed08","repo":"permissions-dispatcher/PermissionsDispatcher","slug":"e-simplestring-has-duplicated-needsperm","errorCode":null,"errorMessage":"'${e.simpleString()}()' has duplicated '@NeedsPermission' method. The method annotated with '@NeedsPermission' must has the unique name.","messagePattern":"'(.+?)\\(\\)' has duplicated '@NeedsPermission' method\\. The method annotated with '@NeedsPermission' must has the unique name\\.","errorType":"validation","errorClass":"DuplicatedMethodNameException","httpStatus":null,"severity":"error","filePath":"processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt","lineNumber":137,"sourceCode":"                throw MixPermissionTypeException(it, SYSTEM_ALERT_WINDOW)\n            }\n        }\n    }\n}\n\nfun checkSpecialPermissionsWithNeverAskAgain(items: List<ExecutableElement>, annotationClass: Class<OnNeverAskAgain> = OnNeverAskAgain::class.java) {\n    items.forEach {\n        val permissionValue = it.getAnnotation(annotationClass).permissionValue()\n        if (permissionValue.contains(WRITE_SETTINGS) || permissionValue.contains(SYSTEM_ALERT_WINDOW)) {\n            throw SpecialPermissionsWithNeverAskAgainException()\n        }\n    }\n}\n\nfun checkDuplicatedMethodName(items: List<ExecutableElement>) {\n    items.forEach { item ->\n        items.firstOrNull { it != item && it.simpleName == item.simpleName }?.let {\n            throw DuplicatedMethodNameException(item)\n        }\n    }\n}\n","sourceCodeStart":119,"sourceCodeEnd":141,"githubUrl":"https://github.com/permissions-dispatcher/PermissionsDispatcher/blob/74b532bf1fe430fb12ad8414b80399f2d7cfc954/processor/src/main/kotlin/permissions/dispatcher/processor/util/Validators.kt#L119-L141","documentation":"The PermissionsDispatcher processor requires every @NeedsPermission-annotated method in a class to have a unique simple name, because generated dispatcher code references these methods by name. Two annotated methods with the same name (e.g. Java overloads, or same-named methods in a class hierarchy) make the generated binding ambiguous, so compilation fails.","triggerScenarios":"Declaring two @NeedsPermission methods with identical simpleName in the same class (e.g. overloads fun request() and fun request(s: String)), or having a subclass and superclass both declare @NeedsPermission methods with the same simple name that the processor sees together.","commonSituations":"Java-style method overloading carried into Kotlin annotated methods; refactoring two features to reuse a generic name like 'request' or 'onPermission'; inheritance hierarchies where a base class's annotated method name is reused in a subclass.","solutions":["Rename one of the duplicated @NeedsPermission methods to a unique, descriptive name","Merge overloads into a single annotated method with default parameters instead of multiple same-named overloads","If the clash comes from inheritance, rename the subclass method or remove the annotation from one level"],"exampleFix":"// before\n@NeedsPermission(Manifest.permission.CAMERA)\nfun request() { }\n\n@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)\nfun request() { }\n\n// after\n@NeedsPermission(Manifest.permission.CAMERA)\nfun requestCamera() { }\n\n@NeedsPermission(Manifest.permission.ACCESS_FINE_LOCATION)\nfun requestLocation() { }","handlingStrategy":"validation","validationCode":"// scan for duplicate simple names among @NeedsPermission methods before building\nval annotated = listOf(\"requestCamera\", \"requestLocation\") // names of @NeedsPermission methods\nval duplicates = annotated.groupingBy { it }.eachCount().filterValues { it > 1 }\nrequire(duplicates.isEmpty()) { \"Duplicate @NeedsPermission method names: $duplicates\" }","typeGuard":"fun List<String>.hasUniqueNames(): Boolean = size == distinct().size\n\nrequire(annotatedMethodNames.hasUniqueNames()) { \"@NeedsPermission methods must have unique names\" }","tryCatchPattern":null,"preventionTips":["Never overload @NeedsPermission-annotated methods; use unique descriptive names per permission set","Prefer Kotlin default parameters over overloads for optional arguments on annotated methods","When using inheritance, ensure subclass annotated methods do not reuse base-class annotated method names"],"tags":["kotlin","annotation-processor","duplicate-method","compile-time"],"backgroundTag":"schema-validation-failed","analyzedSha":"74b532bf1fe430fb12ad8414b80399f2d7cfc954","analyzedAt":"2026-09-08T21:44:58.380Z","contentChangedAt":"2026-09-08T21:44:58.380Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}