Yarikx / reductor

Redux for Android. Predictable state container library for Java/Android
Apache License 2.0
463 stars 27 forks source link

(ProGuard) Looking for a constructor that does not exist #16

Closed stoyicker closed 7 years ago

stoyicker commented 7 years ago

With ProGuard enabled, I get this error:

Warning: MyAppStateReducer$Builder: can't find referenced method 'MyAppStateReducer(com.yheriatovych.reductor.Reducer,MyAppStateReducer$1)' in program class MyAppStateReducer

which I find interesting because my code for MyAppStateReducer is just a dummy and it does not have a sub-class nor a constructor taking two parameters:

class AppStateReducer(val peopleListReducer: Reducer<List<Person>>): Reducer<AppState> {

    override fun reduce(state: AppState, action: Action): AppState {
        val initialPersonList = state.personList()
        val reducedPersonList = peopleListReducer.reduce(initialPersonList, action)

        return if (initialPersonList == reducedPersonList) {
            state
        } else {
            AppState.createFrom(reducedPersonList)
        }
    }
}

It compiles without ProGuard though which I don't undestand because although a Builder class is created, there is still no two-parameter constructor.

Yarikx commented 7 years ago

Hi, interesting case.

It should not affect proguard as most of the generated code is used directly (without reflection). However as I can see maybe there is some interesting combination of Kotlin, proguard, generated code.

I didn't heavily test Reductor on how it works with Kotlin yet, but probably I should.

Can you create a minimal project to reproduce this issue?

stoyicker commented 7 years ago

Unfortunately I have this setup at work and can't share the source, but I will create an mwe as soon as I have time home.

Yarikx commented 7 years ago

Thanks, that would be great! I will try to reproduce it by myself.

stoyicker commented 7 years ago

https://github.com/stoyicker/reductor-issue-16-mwe

Yarikx commented 7 years ago

Thank you! I'll check the issue soon.

On Thu, 1 Dec 2016, 09:11 Jorge Antonio Díaz-Benito Soriano, < notifications@github.com> wrote:

https://github.com/stoyicker/reductor-issue-16-mwe

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Yarikx/reductor/issues/16#issuecomment-264119739, or mute the thread https://github.com/notifications/unsubscribe-auth/AALPt4czm1x5nke_6-ecNdOUOSaCNAYRks5rDo9VgaJpZM4LAFqH .

Yarikx commented 7 years ago

Ok, Now I see what the issue is about. The problem is that you defined the class AppStateReducer which is also generated.

As you annotated your state with @CombinedState that means that reductor will generate reducer that delegates actions to sub reducers. And as I can see you are doing this manually in AppStateReducer

So in your case, you can either

stoyicker commented 7 years ago

That makes a lot of sense, thanks.