Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,21 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
internal val DeclarationDescriptor.isRefined: Boolean
get() = annotations.any { annotation ->
!annotation.isNativeCoroutinesAnnotation && annotation.isRefinementAnnotation
}
} || (containingDeclaration?.isHiddenFromObjC ?: false)

private val DeclarationDescriptor.isHiddenFromObjC: Boolean
get() = annotations.any { annotation ->
annotation.isHiddenFromObjCAnnotation
} || (containingDeclaration?.isHiddenFromObjC ?: false)

@Suppress("UnstableApiUsage")
private val AnnotationDescriptor.isRefinementAnnotation: Boolean
get() = annotationClass?.annotations?.any { metaAnnotation ->
val fqName = metaAnnotation.fqName
fqName == FqNames.hidesFromObjC || fqName == FqNames.refinesInSwift
} ?: false

private val AnnotationDescriptor.isHiddenFromObjCAnnotation: Boolean
get() = annotationClass?.annotations?.any { metaAnnotation ->
metaAnnotation.fqName == FqNames.hidesFromObjC
} ?: false
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,31 @@ package com.rickclephas.kmp.nativecoroutines.compiler.fir.utils
import com.rickclephas.kmp.nativecoroutines.compiler.utils.ClassIds
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
import org.jetbrains.kotlin.fir.declarations.toAnnotationClassId
import org.jetbrains.kotlin.fir.declarations.toAnnotationClassLikeSymbol
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
import org.jetbrains.kotlin.fir.resolve.getContainingClass
import org.jetbrains.kotlin.fir.resolve.getContainingDeclaration

internal fun FirCallableDeclaration.isRefined(session: FirSession): Boolean =
annotations.any { annotation ->
!annotation.isNativeCoroutinesAnnotation(session) && annotation.isRefinementAnnotation(session)
}
} || (getContainingClass()?.isHiddenFromObjC(session) ?: false)

private fun FirClassLikeDeclaration.isHiddenFromObjC(session: FirSession): Boolean =
annotations.any { annotation ->
annotation.isHidingFromObjCAnnotation(session)
} || (getContainingDeclaration(session)?.isHiddenFromObjC(session) ?: false)

private fun FirAnnotation.isRefinementAnnotation(session: FirSession): Boolean =
toAnnotationClassLikeSymbol(session)?.resolvedAnnotationsWithClassIds.orEmpty().any { metaAnnotation ->
val classId = metaAnnotation.toAnnotationClassId(session)
classId == ClassIds.hidesFromObjC || classId == ClassIds.refinesInSwift
}

private fun FirAnnotation.isHidingFromObjCAnnotation(session: FirSession): Boolean =
toAnnotationClassLikeSymbol(session)?.resolvedAnnotationsWithClassIds.orEmpty().any { metaAnnotation ->
val classId = metaAnnotation.toAnnotationClassId(session)
classId == ClassIds.hidesFromObjC
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,20 @@ interface TestInterface {
val flowInterfaceProperty: Flow<Int>
}

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface TestHiddenFromObjCInterface {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>

class Nested {
suspend fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: Flow<Int> = throw Throwable()
}
}

class TestClassA: TestInterface {

override suspend fun suspendInterfaceFunction(): Int = 0
Expand Down Expand Up @@ -120,3 +134,19 @@ actual class TestClassC {

actual val flowProperty: Flow<Int> get() = throw Throwable()
}

class TestClassD {
@NativeCoroutines
suspend fun suspendInterfaceFunction(): Int = 0

@NativeCoroutines
val flowInterfaceProperty: Flow<Int> = throw Throwable()

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface Nested {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ interface TestInterface {
val flowInterfaceProperty: <!EXPOSED_FLOW_TYPE_ERROR!>Flow<Int><!>
}

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface TestHiddenFromObjCInterface {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>

class Nested {
suspend fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: Flow<Int> = throw Throwable()
}
}

class TestClassA: TestInterface {

override suspend fun suspendInterfaceFunction(): Int = 0
Expand Down Expand Up @@ -96,3 +110,17 @@ actual class TestClassC {

actual val flowProperty: Flow<Int> get() = throw Throwable()
}

class TestClassD {
<!EXPOSED_SUSPEND_FUNCTION_ERROR!>suspend<!> fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: <!EXPOSED_FLOW_TYPE_ERROR!>Flow<Int><!> = throw Throwable()

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface Nested {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ interface TestInterface {
val flowInterfaceProperty: Flow<Int>
}

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface TestHiddenFromObjCInterface {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>

class Nested {
suspend fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: Flow<Int> = throw Throwable()
}
}

class TestClassA: TestInterface {

override suspend fun suspendInterfaceFunction(): Int = 0
Expand Down Expand Up @@ -96,3 +110,17 @@ actual class TestClassC {

actual val flowProperty: Flow<Int> get() = throw Throwable()
}

class TestClassD {
suspend fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: Flow<Int> = throw Throwable()

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface Nested {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ interface TestInterface {
val flowInterfaceProperty: <!EXPOSED_FLOW_TYPE!>Flow<Int><!>
}

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface TestHiddenFromObjCInterface {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>

class Nested {
suspend fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: Flow<Int> = throw Throwable()
}
}

class TestClassA: TestInterface {

override suspend fun suspendInterfaceFunction(): Int = 0
Expand Down Expand Up @@ -96,3 +110,17 @@ actual class TestClassC {

actual val flowProperty: Flow<Int> get() = throw Throwable()
}

class TestClassD {
<!EXPOSED_SUSPEND_FUNCTION!>suspend<!> fun suspendInterfaceFunction(): Int = 0

val flowInterfaceProperty: <!EXPOSED_FLOW_TYPE!>Flow<Int><!> = throw Throwable()

@OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
interface Nested {
suspend fun suspendInterfaceFunction(): Int

val flowInterfaceProperty: Flow<Int>
}
}