[K/N] Fix DeclarationDescriptor.findObjCExportMetaAnnotations
`require` is failing in the presence of error types, so use nullability instead.
This commit is contained in:
committed by
Space Team
parent
b6060f8440
commit
becbca2284
+5
-3
@@ -23,8 +23,10 @@ internal data class ObjCExportMetaAnnotations(
|
|||||||
val refinesInSwiftAnnotation: AnnotationDescriptor?,
|
val refinesInSwiftAnnotation: AnnotationDescriptor?,
|
||||||
)
|
)
|
||||||
|
|
||||||
internal fun DeclarationDescriptor.findObjCExportMetaAnnotations(): ObjCExportMetaAnnotations {
|
internal fun DeclarationDescriptor.findObjCExportMetaAnnotations(): ObjCExportMetaAnnotations? {
|
||||||
require(this is ClassDescriptor && this.kind == ClassKind.ANNOTATION_CLASS)
|
if (this !is ClassDescriptor || this.kind != ClassKind.ANNOTATION_CLASS) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
var objCAnnotation: AnnotationDescriptor? = null
|
var objCAnnotation: AnnotationDescriptor? = null
|
||||||
var swiftAnnotation: AnnotationDescriptor? = null
|
var swiftAnnotation: AnnotationDescriptor? = null
|
||||||
for (annotation in annotations) {
|
for (annotation in annotations) {
|
||||||
@@ -44,7 +46,7 @@ object NativeObjCRefinementAnnotationChecker : DeclarationChecker {
|
|||||||
|
|
||||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||||
if (descriptor !is ClassDescriptor || descriptor.kind != ClassKind.ANNOTATION_CLASS) return
|
if (descriptor !is ClassDescriptor || descriptor.kind != ClassKind.ANNOTATION_CLASS) return
|
||||||
val (objCAnnotation, swiftAnnotation) = descriptor.findObjCExportMetaAnnotations()
|
val (objCAnnotation, swiftAnnotation) = descriptor.findObjCExportMetaAnnotations() ?: return
|
||||||
if (objCAnnotation == null && swiftAnnotation == null) return
|
if (objCAnnotation == null && swiftAnnotation == null) return
|
||||||
if (objCAnnotation != null && swiftAnnotation != null) {
|
if (objCAnnotation != null && swiftAnnotation != null) {
|
||||||
val reportLocation = DescriptorToSourceUtils.getSourceFromAnnotation(swiftAnnotation) ?: declaration
|
val reportLocation = DescriptorToSourceUtils.getSourceFromAnnotation(swiftAnnotation) ?: declaration
|
||||||
|
|||||||
Reference in New Issue
Block a user