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

Prefer non-synthetic methods in findAnnotationWithOverrides #1160

Merged
merged 1 commit into from Sep 4, 2019

Conversation

@swankjesse
Copy link
Collaborator

commented Aug 17, 2019

Closes: #1159

@swankjesse swankjesse force-pushed the jwilson.0818.synthetic branch from 87b085a to e2ebf8a Aug 26, 2019

@swankjesse swankjesse force-pushed the jwilson.0818.synthetic branch from e2ebf8a to c6967df Aug 26, 2019

internal fun Method.preferNonSynthetic(): Method {
if (!isSynthetic) return this

for (peer in declaringClass.methods) {

This comment has been minimized.

Copy link
@adrw

adrw Sep 4, 2019

Collaborator

Is there a case where there are multiple non-synthetic methods returned? Or is there only ever two choices: synthetic + non-synthetic?

This comment has been minimized.

Copy link
@swankjesse

swankjesse Sep 4, 2019

Author Collaborator

there can be multiple synthetic methods!

@@ -61,3 +62,45 @@ internal fun Class<*>.superclasses(): Set<Class<*>> {
}
return result
}

/**
* Attempts to find a non-synthetic method with the same declaring class, name, and parameters. If

This comment has been minimized.

Copy link
@adrw

adrw Sep 4, 2019

Collaborator

Thanks for the docs, helps to understand the purpose (and flakiness without) this code!

@adrw
adrw approved these changes Sep 4, 2019

@swankjesse swankjesse merged commit 7ec266f into master Sep 4, 2019

2 checks passed

ci/circleci: java Your tests passed on CircleCI!
Details
ci/circleci: node Your tests passed on CircleCI!
Details
*
* We prefer non-synthetic methods for reflection because that's where annotations will be.
*/
internal fun Method.preferNonSynthetic(): Method {

This comment has been minimized.

Copy link
@tomjadams

tomjadams Sep 4, 2019

nit: This name reads to me like it should have a boolean return type, would a better name be nonSyntheticIfAvailable? I don't think that's much better though TBH :)

@swankjesse swankjesse deleted the jwilson.0818.synthetic branch Sep 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.