-
Notifications
You must be signed in to change notification settings - Fork 294
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 for type hierarchy while checking overrides #124
Conversation
compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt
Outdated
Show resolved
Hide resolved
val typeOverride = subClassDescription.getAllSuperClassifiers() | ||
.filter { it != subClassDescription } // exclude subclass itself as it cannot override its own methods | ||
.any { | ||
it == superClassDescription |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can these 2 lamdas be merged into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sequence<ClassifierDescriptor>
returns a sequence so i kept them separate for readability (and does not have the cost of creating intermediate lists).
happy to change if you have a strong preference.
compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processor/CheckOverrideProcessor.kt
Show resolved
Hide resolved
LGTM. Can you rebase commit history a little bit or would you like me to squash them all into one? |
compiler-plugin/src/main/kotlin/com/google/devtools/ksp/processing/impl/ResolverImpl.kt
Outdated
Show resolved
Hide resolved
There was a bug in overrides check where superClass.foo overrides subClass.foo would return true even though super class cannot override a subClass. This PR fixes that issue by checking for class hiearchy in addition to the method signature. Fixes: google#123 Test: CheckOverrideProcessor
f17f13b
to
b9ceceb
Compare
ready for merge. rebased manually with a proper single commit message. |
Merged into master, thanks for contribution! |
This PR fixes a bug where override would return
true
if base method is sent as the overrider.Similarly, it was also returning true when override is called with the same function itself.
I've also changed the override util call to also check for return type.
Fixes: #123