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

Use property descriptor impl for java properties #217

Merged
merged 1 commit into from
Dec 29, 2020
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 @@ -40,7 +40,7 @@ class AllFunctionsProcessor : AbstractTestProcessor() {
return "${this.simpleName.asString()}" +
"(${this.parameters.map {
buildString {
append(it.type?.resolve()?.declaration?.qualifiedName?.asString())
append(it.type.resolve().declaration.qualifiedName?.asString())
if (it.hasDefault) {
append("(hasDefault)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ internal fun PropertyDescriptor.toKSPropertyDeclaration(): KSPropertyDeclaration
is KtProperty -> KSPropertyDeclarationImpl.getCached(psi)
is KtParameter -> KSPropertyDeclarationParameterImpl.getCached(psi)
is PsiField -> KSPropertyDeclarationJavaImpl.getCached(psi)
is PsiMethod -> {
// happens when a java class implements a kotlin interface that declares properties.
KSPropertyDeclarationDescriptorImpl.getCached(this)
}
else -> throw IllegalStateException("unexpected psi: ${psi.javaClass}")
}
}
Expand Down
27 changes: 26 additions & 1 deletion compiler-plugin/testData/api/allFunctions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
// WITH_RUNTIME
// TEST PROCESSOR: AllFunctionsProcessor
// EXPECTED:
// class: Foo
// class: KotlinInterfaceWithProperty
// <init>(): C
// <init>(): JavaImplOfKotlinInterface
// a
// aFromC
// aFromC
Expand All @@ -30,18 +31,24 @@
// cFromC
// class: C
// class: Data
// class: Foo
// class: JavaImplOfKotlinInterface
// component1(): kotlin.String
// contains(kotlin.Number): kotlin.Boolean
// containsAll(kotlin.collections.Collection): kotlin.Boolean
// copy(kotlin.String(hasDefault)): Data
// equals(kotlin.Any): kotlin.Boolean
// equals(kotlin.Any): kotlin.Boolean
// equals(kotlin.Any): kotlin.Boolean
// equals(kotlin.Any): kotlin.Boolean
// equals(kotlin.Any): kotlin.Boolean
// forEach(java.util.function.Consumer): kotlin.Unit
// get(kotlin.Int): kotlin.Number
// hashCode(): kotlin.Int
// hashCode(): kotlin.Int
// hashCode(): kotlin.Int
// hashCode(): kotlin.Int
// hashCode(): kotlin.Int
// indexOf(kotlin.Number): kotlin.Int
// isEmpty(): kotlin.Boolean
// iterator(): kotlin.collections.Iterator
Expand All @@ -61,6 +68,10 @@
// toString(): kotlin.String
// toString(): kotlin.String
// toString(): kotlin.String
// toString(): kotlin.String
// toString(): kotlin.String
// x
// x
// END
// FILE: a.kt
abstract class Foo : C(), List<out Number> {
Expand Down Expand Up @@ -102,3 +113,17 @@ class C {
return "str"
}
}

// FILE: KotlinInterfaceWithProperty.kt
interface KotlinInterfaceWithProperty {
var x:Int
}

// FILE: JavaImplOfKotlinInterface.java
class JavaImplOfKotlinInterface implements KotlinInterfaceWithProperty {
public int getX() {
return 1;
}
public void setX(int value) {
}
}