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

shh for Runnable #29

Closed
2 tasks done
kevin-lee opened this issue May 28, 2017 · 2 comments · Fixed by #65
Closed
2 tasks done

shh for Runnable #29

kevin-lee opened this issue May 28, 2017 · 2 comments · Fixed by #65
Assignees
Labels
Milestone

Comments

@kevin-lee
Copy link
Owner

kevin-lee commented May 28, 2017

This is a sub-task for shh for more functions (#28).

  • Add AnnoyingRunnable and AnnoyingRunner types
  • Add support for AnnoyingRunnable and AnnoyingRunner
@kevin-lee kevin-lee added the task label May 28, 2017
@kevin-lee kevin-lee self-assigned this May 28, 2017
@kevin-lee kevin-lee mentioned this issue May 28, 2017
4 tasks
@kevin-lee
Copy link
Owner Author

Problem

Passing a lambda expression or method reference for AnnoyingRunnable or AnnoyingRunner to shh has an issue with the following error.

Ambiguos method call. Both shh(AnnoyingRunnable) in AnnoyingFuns and shh(AnnoyingRunner) in AnnoyingFuns match.

Both AnnoyingRunnable and AnnoyingRunner have SAM with exactly the same method signature so the compiler can't figure out the given lambda expression to method reference is for which FunctionalInterface type.

@kevin-lee
Copy link
Owner Author

Solution

The problem described above has been solved by using Liskov substitution principle.

Before

  • Runner wasn't a sub-type of Runnable
  • AnnoyingRunner wasn't a sub-type of AnnoyingRunnable
  • There is a shh method taking AnnoyingRunnable and then returns Runnable.
  • There is a shh method taking AnnoyingRunner and then returns Runner.

After

  • Runner is a sub-type of Runnable.
  • AnnoyingRunner is a sub-type of AnnoyingRunnable.
  • There is only one shh method which takes AnnoyingRunnable then returns Runner.

kevin-lee added a commit that referenced this issue Jun 16, 2017
- There is a shh method taking AnnoyingRunnable then returns Runner so that any nullary function case can be solved.
kevin-lee added a commit that referenced this issue Jun 23, 2017
@kevin-lee kevin-lee reopened this Jun 23, 2017
kevin-lee added a commit that referenced this issue Nov 16, 2019
- There is a shh method taking AnnoyingRunnable then returns Runner so that any nullary function case can be solved.
kevin-lee added a commit that referenced this issue Nov 16, 2019
@kevin-lee kevin-lee added this to the 0.0.16 milestone Nov 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant