Skip to content

Conversation

@nikolaykasyanov
Copy link

@nikolaykasyanov nikolaykasyanov commented Dec 30, 2025

This PR builds on #164 to suppress exposed suspend function/flow warnings when the containing type is annotated with an annotation that @HidesFromObjC.

I find this PR helpful on its own, but ideally something like this should lead to a warning:

@HiddenFromObjC
interface TestHiddenFromObjCInterface {
    @NativeCoroutinesIgnore // redundant annotation
    suspend fun suspendInterfaceFunction(): Int

    val flowInterfaceProperty: Flow<Int>
}

Happy New Year! 🎉

!annotation.isNativeCoroutinesAnnotation(session) && annotation.isRefinementAnnotation(session)
}

internal fun FirClassLikeDeclaration.isRefined(session: FirSession): Boolean =
Copy link
Author

@nikolaykasyanov nikolaykasyanov Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isRefined is probably not the best name here as types can't be annotated with @RefinesInSwift, so the only option is @HidesFromObjC.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

val annotations = declaration.getNativeCoroutinesAnnotations(context.session)
val isRefined = declaration.isRefined(context.session)
val isRefined =
declaration.isRefined(context.session) || (declaration.getContainingClass()?.isRefined(context.session)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the second thought, the whole containment chain needs to be checked for cases where the top-level class is hidden & nested classes have suspend functions/flows.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed.

Copy link
Owner

@rickclephas rickclephas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

I find this PR helpful on its own, but ideally something like this should lead to a warning:

Yeah that would indeed be nice, I'll take a look 👍🏻 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants