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

Make TypedResource covariant in A #288

Open
iphydf opened this issue Oct 5, 2016 · 4 comments
Open

Make TypedResource covariant in A #288

iphydf opened this issue Oct 5, 2016 · 4 comments

Comments

@iphydf
Copy link

iphydf commented Oct 5, 2016

Just like one can implicitly convert a ViewGroup to a View, we should be able to pass a TypedResource[ViewGroup] as TypedResource[View].

Workaround:

object TRUtil {
  def convert[A1, A2 <: A1](tr: TypedResource[A2]): TypedResource[A1] = {
    TypedResource[A1](tr.id)
  }
}
@pfn
Copy link
Member

pfn commented Oct 5, 2016

What is the use-case?

On Wed, Oct 5, 2016 at 8:42 AM iphydf notifications@github.com wrote:

Just like one can implicitly convert a ViewGroup to a View, we should be
able to pass a TypedResource[ViewGroup] as TypedResource[View].

Workaround:

object TRUtil {
def convert[A1, A2 <: A1](tr: TypedResource[A2]): TypedResource[A1] = {
TypedResourceA1
}
}


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#288, or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAfQxX7kqDgZrVLPT1XuQHlS403Sb_I1ks5qw8VogaJpZM4KO9w1
.

@iphydf
Copy link
Author

iphydf commented Oct 5, 2016

The use case is no longer there. I used to pass TypedResource around, but in my case I could actually just pass the View around. In general, what is the harm in adding covariance?

@pfn
Copy link
Member

pfn commented Oct 12, 2016

I'd rather have a compelling reason to add covariance rather than vice versa

@chenakam
Copy link

chenakam commented Nov 16, 2017

I think add "+" to TypedResource[A] means TypedResource[+A] is faultless. No logical problems will triggered. TypedViewHolder[+T <: View] the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants