EDIT: Here's the kotlin issue in Youtrack
Hi,
I tried using complied repositories in kotlin, first manually, by writing the code myself in a new kotlin class, but with no success. I then tried to convert the CalculatorActivityFinal.java
file to to kotlin with the IDE option (cmd+option+shift+K) (requires the IntelliJ/Android Studio Kotlin plugin), and the generated code couldn't compile either, displaying the same error.
This seems to be related to how kotlin handles generics type safety.
Here's what I see after converting code to kotlin (all the errors are in onStart()
):
Note that the code above was generated after converting all lambdas to anonymous classes.
The main problematic line is the repository compilation:
mResultRepository = Repositories.repositoryWithInitialValue(Result.absent<String>()).observe(mValue1Repo, mValue2Repo, mOperationSelector).onUpdatesPerLoop().goTo(CalculatorExecutor.EXECUTOR).attemptTransform(Function<com.google.android.agera.Result<kotlin.String>, com.google.android.agera.Result<com.google.android.agera.Result<kotlin.String>>> { input1 -> CalculatorOperations.keepCpuBusy(input1) }).orEnd(Function<kotlin.Throwable, com.google.android.agera.Result<kotlin.String>> { failure -> Result.failure<String>(failure) }).getFrom(mValue1Repo).mergeIn(mValue2Repo, Merger<kotlin.Int, kotlin.Int, android.support.v4.util.Pair<kotlin.Int, kotlin.Int>> { a, b -> Pair.create(a, b) }).attemptMergeIn(mOperationSelector, Merger<android.support.v4.util.Pair<kotlin.Int, kotlin.Int>, com.google.android.agera.Result<kotlin.Int>, com.google.android.agera.Result<kotlin.Int>> { operands, operation -> CalculatorOperations.attemptOperation(operands, operation) }).orEnd(Function<kotlin.Throwable, com.google.android.agera.Result<kotlin.String>> { failure -> Result.failure<String>(failure) }).thenTransform(Function<kotlin.Int, com.google.android.agera.Result<kotlin.String>> { input -> Result.present(input.toString()) }).onConcurrentUpdate(RepositoryConfig.SEND_INTERRUPT).compile()
Before trying with anonymous classes, I tried converting the codes with lambdas, which did not work too as you can see in the following screenshot:
I think it's absolutely impossible to compile an agera repository in kotlin with agera 1.1.0 and kotlin 1.0.5, so I'm asking how agera, or kotlin may be edited to support such cases