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

FIx findOverridee for properties, fixes #174 #176

Merged
merged 1 commit into from Nov 30, 2020

Conversation

yigit
Copy link
Collaborator

@yigit yigit commented Nov 27, 2020

This CL updates KSPropertyDecl.findOverridee to use the same infra
that is used by KSFunctionDeclaration.

Fixes: #174

This CL updates KSPropertyDecl.findOverridee to use the same infra
that is used by KSFunctionDeclaration.

Fixes: google#174
Copy link
Collaborator

@neetopia neetopia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overriding for properties usually get complicated when it involves Java, can you add a test case where Java code is overriding a property declared in Kotlin code? See this for example.

*
* When there are multiple super classes / interfaces with the property, the closest declaration
* to the current containing declaration is selected. If they are in the same level, the
* property of the first specified interface (in source) will be returned.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: specified super class or interface instead of specified interface

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overriding for properties usually get complicated when it involves Java, can you add a test case where Java code is overriding a property declared in Kotlin code? See this for example.

the findOverridee in the java implementation of property is not implemented (just returns null). I'm guessing that is because java fields do not override parents.

You mean there is a base kotlin class with val x:T and java overrides it with getX():T?
I'll give it a try but that makes me think, that would mean the findOverridee of KSFunction would need to return a KSPropertyAccessor that does not implement KSFunction :/.
I'll see what happens there.

There was also some work discussed before where KSP right now does not properly resolve property accessors in java source code. If we do, then we should also implement findOverridee in KSPropertyDeclaration.

Copy link
Collaborator Author

@yigit yigit Nov 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually trying to reproduce that hits this issue: (same exception)
#94

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm actually able to workaround that issue by making KSJavaFileImpl use descriptors for the class instead of Java impls.
Java impls are causing lots of inconsistencies hence created this issue:
#177

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this so fast.

Question: is the merge of this PR blocked by the progress on #177? Or can this be merged already? It would help me a lot: until this is fixed, I need to maintain my fork. I use Kotlin only. :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neetopia wdyt? I think this one is fine to merge as it should be an improvement over what we have (fixes kotlin properties, java is still broken).
#177 probably won't happen or if it happens it will take a long time.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll merge this one.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the merge. Is it possible to create a release that contains this? I am using KSP as a dependency.
If not, what is a likely date for a new release, given your release schedule?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do a release this Friday PST.

@neetopia neetopia merged commit 9e607cd into google:master Nov 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should KSPropertyDeclarationImpl.findOverridee use singleOrNull?
3 participants