8000 Act java synthetic property method as member function by bacecek · Pull Request #2497 · google/ksp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Act java synthetic property method as member function #2497

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -52,6 +52,7 @@ class KSFunctionDeclarationImpl private constructor(internal val ktFunctionSymbo
}
}
KaSymbolLocation.TOP_LEVEL -> FunctionKind.TOP_LEVEL
KaSymbolLocation.PROPERTY -> FunctionKind.MEMBER
else -> throw IllegalStateException("Unexpected location ${ktFunctionSymbol.location}")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ open class FunctionKindProcessor : AbstractTestProcessor() {
override fun process(resolver: Resolver): List<KSAnnotated> {
fun KSFunctionDeclaration.pretty(): String {
val name = if (parentDeclaration != null) {
val className = parentDeclaration?.simpleName?.asString() ?: ""
val parentClass = when (val parent = parentDeclaration) {
// Fix for https://github.com/google/ksp/issues/2498. Must be removed after fixing the original issue.
is KSPropertyDeclaration -> parent.parentDeclaration
else -> parentDeclaration
}
val className = parentClass?.simpleName?.asString() ?: ""
if (className.isNotEmpty()) {
"$className.${simpleName.asString()}"
} else {
Expand Down
13 changes: 13 additions & 0 deletions test-utils/testData/api/functionKinds.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
// MyClass.suspendMethod: MEMBER
// MyInterface.method: MEMBER
// MyInterface.methodWithImpl: MEMBER
// MyInterfaceImplJava.<init>: MEMBER
// MyInterfaceImplJava.getProperty: MEMBER
// MyInterfaceImplJava.method: MEMBER
// topLevelMethod: TOP_LEVEL
// topLevelSuspendMethod: TOP_LEVEL
// END
Expand All @@ -51,6 +54,7 @@ class MyClass {
interface MyInterface {
fun method()
fun methodWithImpl() {}
val property: Int
}

// FILE: JavaClass.java
Expand All @@ -64,3 +68,12 @@ interface JavaInterface {
void methodInInterface();
static void staticMethodInInterface() {}
}

// FILE: MyInterfaceImplJava.java
class MyInterfaceImplJava implements MyInterface {
@Override
public void method() {}

@Override
public int getProperty() { return 0; }
}
0