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

Change strategy inheritance algorithm #70

Closed
aasitnikov opened this issue Nov 10, 2019 · 0 comments · Fixed by #71
Closed

Change strategy inheritance algorithm #70

aasitnikov opened this issue Nov 10, 2019 · 0 comments · Fixed by #71
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@aasitnikov
Copy link
Member

In current compiler implementation child interface state strategy propogated to superinterface, which can be source of hard to find bugs.

Consider following snippet:

interface ErrorView : MvpView {
    fun showErrorDialog(error: String)
}

@StateStrategyType(OneExecutionStateStrategy::class)
interface OneExecutionView : ErrorView {
    fun oneExecutionFunction()
}

@StateStrategyType(AddToEndSingleStrategy::class)
interface AddToEndSingleView : ErrorView {
    fun addToEndFunction()
}

Note that the ErrorView interface does not define any strategy, and two different child interfaces define different strategies.
In the current implementation generated viewstates will have following state strategies:

class AddToEndSingleView$$State : AddToEndSingleView {
    fun addToEndFunction() -> AddToEndSingleStrategy::class
    fun showErrorDialog(error: String) -> AddToEndSingleStrategy::class
}

class OneExecutionView$$State : OneExecutionView {
    fun oneExecutionFunction() ->  OneExecutionStateStrategy:class
    fun showErrorDialog(String error) -> OneExecutionStateStrategy::class
}

As you can see method showErrorDialog() has different strategies in different views.

Superinterface strategies should be evaluated without influence from child interfaces and vice-versa. So following behaviour proposed:

  1. Each view interface must have all strategies defined in it, even if it's not used directly and only used as superinteface.
  2. If interface has methods without strategies, compilation should fail.
  3. If superinterface method is overriden by child interface, than it should have child strategy, whether it's defined directly on the method or on the child interface. Methods are compared by name and parameter types.
  4. Superinterface strategy is not inherited. If child interface has no interface strategy and some method in it is defined without any strategy, than compilation should fail.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant