Skip to content

Commit 8ba1502

Browse files
committed
Act java synthetic property method as member function
1 parent ab9274e commit 8ba1502

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

kotlin-analysis-api/src/main/kotlin/com/google/devtools/ksp/impl/symbol/kotlin/KSFunctionDeclarationImpl.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class KSFunctionDeclarationImpl private constructor(internal val ktFunctionSymbo
5252
}
5353
}
5454
KaSymbolLocation.TOP_LEVEL -> FunctionKind.TOP_LEVEL
55+
KaSymbolLocation.PROPERTY -> FunctionKind.MEMBER
5556
else -> throw IllegalStateException("Unexpected location ${ktFunctionSymbol.location}")
5657
}
5758
}

test-utils/src/main/kotlin/com/google/devtools/ksp/processor/FunctionKindProcessor.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ open class FunctionKindProcessor : AbstractTestProcessor() {
2727
override fun process(resolver: Resolver): List<KSAnnotated> {
2828
fun KSFunctionDeclaration.pretty(): String {
2929
val name = if (parentDeclaration != null) {
30-
val className = parentDeclaration?.simpleName?.asString() ?: ""
30+
val parentClass = when (val parent = parentDeclaration) {
31+
is KSPropertyDeclaration -> parent.parentDeclaration
32+
else -> parentDeclaration
33+
}
34+
val className = parentClass?.simpleName?.asString() ?: ""
3135
if (className.isNotEmpty()) {
3236
"$className.${simpleName.asString()}"
3337
} else {

test-utils/testData/api/functionKinds.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
// MyClass.suspendMethod: MEMBER
3030
// MyInterface.method: MEMBER
3131
// MyInterface.methodWithImpl: MEMBER
32+
// MyInterfaceImplJava.<init>: MEMBER
33+
// MyInterfaceImplJava.getProperty: MEMBER
34+
// MyInterfaceImplJava.method: MEMBER
3235
// topLevelMethod: TOP_LEVEL
3336
// topLevelSuspendMethod: TOP_LEVEL
3437
// END
@@ -51,6 +54,7 @@ class MyClass {
5154
interface MyInterface {
5255
fun method()
5356
fun methodWithImpl() {}
57+
val property: Int
5458
}
5559

5660
// FILE: JavaClass.java
@@ -64,3 +68,12 @@ interface JavaInterface {
6468
void methodInInterface();
6569
static void staticMethodInInterface() {}
6670
}
71+
72+
// FILE: MyInterfaceImplJava.java
73+
class MyInterfaceImplJava implements MyInterface {
74+
@Override
75+
public void method() {}
76+
77+
@Override
78+
public int getProperty() { return 0; }
79+
}

0 commit comments

Comments
 (0)