Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check functional interface for modifiers #1872

Merged
merged 2 commits into from
May 7, 2024
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 @@ -211,6 +211,9 @@ internal fun KtClassOrObjectSymbol.toModifiers(): Set<Modifier> {
if (visibility != JavaVisibilities.PackageVisibility) {
result.add(visibility.toModifier())
}
if (isFun) {
result.add(Modifier.FUN)
}
if (isInline) {
result.add(Modifier.INLINE)
}
Expand Down
8 changes: 8 additions & 0 deletions kotlin-analysis-api/testData/javaModifiers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
// OuterKotlinClass: OPEN : PUBLIC
// END
// MODULE: module1
// FILE: ALib.kt
fun interface ALib {
fun test(): Boolean
}
// FILE: DependencyOuterJavaClass.java
public class DependencyOuterJavaClass {
public class DependencyInnerJavaClass {}
Expand Down Expand Up @@ -152,6 +156,10 @@ open class DependencyOuterKotlinClass {
fun synchronizedFun(): String = ""
}
// MODULE: main(module1)
// FILE: ASrc.kt
fun interface ASrc {
fun test(): Boolean
}
// FILE: a.kt
annotation class Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.google.devtools.ksp.processor

import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getClassDeclarationByName
import com.google.devtools.ksp.processing.Resolver
import com.google.devtools.ksp.symbol.*
import com.google.devtools.ksp.symbol.KSPropertyDeclaration
Expand All @@ -31,6 +32,12 @@ class JavaModifierProcessor : AbstractTestProcessor() {
}

override fun process(resolver: Resolver): List<KSAnnotated> {
listOf("ALib", "ASrc").forEach { clsName ->
resolver.getClassDeclarationByName(clsName)!!.let { cls ->
assert(cls.modifiers.contains(Modifier.FUN))
}
}

resolver.getSymbolsWithAnnotation("Test")
.map {
it as KSClassDeclaration
Expand Down
8 changes: 8 additions & 0 deletions test-utils/testData/api/javaModifiers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
// OuterKotlinClass: OPEN : PUBLIC
// END
// MODULE: module1
// FILE: ALib.kt
fun interface ALib {
fun test(): Boolean
}
// FILE: DependencyOuterJavaClass.java
public class DependencyOuterJavaClass {
public class DependencyInnerJavaClass {}
Expand Down Expand Up @@ -152,6 +156,10 @@ open class DependencyOuterKotlinClass {
fun synchronizedFun(): String = ""
}
// MODULE: main(module1)
// FILE: ASrc.kt
fun interface ASrc {
fun test(): Boolean
}
// FILE: a.kt
annotation class Test

Expand Down
Loading