You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
##Workaround##
the workaround solution is to use the .withValue function of the InstanceCreator class, to manually specify the property name to a specific value, before creating the arbitrary object with the .createInstance() function.
##Explanation: ##
Normally before kotlin 1.4, we can specify which class should return what value with the .registerGenerator() function. But since this registerGenerator() is not working anymore, another way is to specify what property name (of the class which you want to create an arbitrary object) should return what value.
##Example##
Given ClassToCreateArbitraryValue has property "property" of type "SomeBusinessClass", instead of
val dataClass = ClassToCreateArbitraryValue::class
val arbitrator = dataClass.arbitrator()
arbitrator.registerGenerator { SomeBusinessClass() }
return arbitrator.createInstance()
do this instead:
val dataClass = ClassToCreateArbitraryValue::class
val arbitrator = dataClass.arbitrator()
arbitrator.apply {
this.withValue("property", SomeBusinessClass())
}
return arbitrator.createInstance()
Hey, this issue was just brought to my attention. Not sure if anyone inside Tyro is watching this repo. I'll have a look soon and see if I can work out how to commit back to this from the outside.
arbitrater v1.0.1 has been released and should be available on maven central shortly. Thanks @thecodinganalyst and @sgerber-prospection for your help with this issue.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The following code in registerGenerator() will always return Any().
Works ok in Kotlin 1.3, but not from Kotlin 1.4 onwards
The text was updated successfully, but these errors were encountered: