Skip to content

Support invariant and covariant type parameters properly. #391

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

Merged
merged 1 commit into from
Oct 18, 2021
Merged

Conversation

vRallev
Copy link
Collaborator

@vRallev vRallev commented Oct 16, 2021

Fixes #388

@vRallev vRallev changed the title Support invariant and covariant type parameter properly. Support invariant and covariant type parameters properly. Oct 16, 2021

other as AssistedService

if (list.size != other.list.size) return false

Choose a reason for hiding this comment

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

Comparing only size seems weird but I guess this is just an example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was lazy...

Choose a reason for hiding this comment

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

Wouldn't if (list != other.list) return false work just as easily? lol

val assistedServiceInstance = factoryImplClass.declaredMethods
.filterNot { it.isStatic }
.single { it.name == "create" }
.invoke(factoryImplInstance, listOf<Class<out String>>())

Choose a reason for hiding this comment

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

nit: replace listOf<Class<out String>>() with a single re-used val list = listOf<Class<out String>>() instance? Perhaps with some items in it too

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This isn't really necessary as it would only test my fake implementation for equals() and hashCode().

@vRallev vRallev merged commit 7497f93 into main Oct 18, 2021
@vRallev vRallev deleted the ralf/388 branch October 18, 2021 15:50
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.

Anvil drops covariance hint for assisted injection factories
2 participants