{"record":{"id":"cc88804e18477906","repo":"Tencent/QMUI_Android","slug":"custommatcher-must-implement-interface-qmuischemem","errorCode":null,"errorMessage":"customMatcher must implement interface QMUISchemeMatcher.","messagePattern":"customMatcher must implement interface QMUISchemeMatcher\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java","lineNumber":361,"sourceCode":"                throw new IllegalStateException(\"customFactory must implement interface QMUISchemeIntentFactory.\");\n            }\n        }else{\n            if (!isSubtypeOfType(typeMirror, QMUISchemeFragmentFactoryType)) {\n                throw new IllegalStateException(\"customFactory must implement interface QMUISchemeFragmentFactory.\");\n            }\n        }\n\n        return CodeBlock.of(\"$T.class\", typeMirror);\n    }\n\n    private CodeBlock generateCustomMatcher(AnnotationMirror annotationMirror){\n        AnnotationValue customFactory = getAnnotationValue(annotationMirror, \"customMatcher\");\n        if (customFactory == null) {\n            return CodeBlock.of(\"null\");\n        }\n        TypeMirror typeMirror = (TypeMirror) customFactory.getValue();\n        if (!isSubtypeOfType(typeMirror, QMUISchemeMatcherType)) {\n            throw new IllegalStateException(\"customMatcher must implement interface QMUISchemeMatcher.\");\n        }\n\n        return CodeBlock.of(\"$T.class\", typeMirror);\n    }\n\n    private CodeBlock generateValueInterceptor(AnnotationMirror annotationMirror){\n        AnnotationValue valueConverter = getAnnotationValue(annotationMirror, \"valueConverter\");\n        if (valueConverter == null) {\n            return CodeBlock.of(\"null\");\n        }\n        TypeMirror typeMirror = (TypeMirror) valueConverter.getValue();\n        if (!isSubtypeOfType(typeMirror, QMUISchemeValueConverterType)) {\n            throw new IllegalStateException(\"customMatcher must implement interface QMUISchemeMatcher.\");\n        }\n\n        return CodeBlock.of(\"$T.class\", typeMirror);\n    }\n","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/arch-compiler/src/main/java/com/qmuiteam/qmui/arch/SchemeProcessor.java#L343-L379","documentation":"SchemeProcessor.generateCustomMatcher validates that the customMatcher annotation value is a subtype of QMUISchemeMatcher. When it is not, the processor throws this IllegalStateException at compile time to prevent generating broken scheme-matching code.","triggerScenarios":"Setting customMatcher in a scheme annotation to a class that does not implement QMUISchemeMatcher.","commonSituations":"Passing an arbitrary class or a matcher written against an older QMUI API; refactored matcher lost the interface; copy-paste of a converter class into the matcher field.","solutions":["Make the customMatcher class implement QMUISchemeMatcher (isScheme matches method).","Check the import refers to com.qmuiteam.qmui.arch.scheme.QMUISchemeMatcher.","Remove the customMatcher attribute if default matching is sufficient."],"exampleFix":"// before\nclass MyMatcher { fun match(...) = true }\n\n// after\nclass MyMatcher : QMUISchemeMatcher { override fun match(uri: Uri, action: String): Boolean = ... }","handlingStrategy":"validation","validationCode":"fun validateMatcher(cls: Class<*>) =\n    check(QMUISchemeMatcher::class.java.isAssignableFrom(cls)) { \"${cls.name} must implement QMUISchemeMatcher\" }","typeGuard":"fun isValidSchemeMatcher(cls: Class<*>): Boolean =\n    QMUISchemeMatcher::class.java.isAssignableFrom(cls)","tryCatchPattern":null,"preventionTips":["Implement QMUISchemeMatcher on every class passed to customMatcher","Match the annotation field to the interface: customMatcher -> QMUISchemeMatcher only","Catch this at development time by building locally before pushing annotation changes"],"tags":["annotation-processor","compile-time","scheme","type-check"],"backgroundTag":"type-mismatch","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}