Dimillian / RedditOS

The product name is Curiosity, a SwiftUI Reddit client for macOS Big Sur
Apache License 2.0
3.95k stars 199 forks source link

Use template where clause to avoid a runtime type test. #14

Open jackpal opened 4 years ago

jackpal commented 4 years ago

Hi Thomas,

Here's what I meant by my tweet saying that I didn't think you needed the runtime type check. The "where" clause turns it into a compile-time type check.

I wasn't able to test this. It builds, but it doesn't look like there's any code in the current project that uses the code that changed, so I don't know if it works or not.

It seems to me that it should work, though. And the assert will at least provide runtime evidence if it's incorrect.

Dimillian commented 3 years ago

If you login and click on your profile it'll load a GenericListContent because it need to displays posts and comments in the same list. With your PR it's not working anymore. It seems like the first initialiser with the where constraints is never called.

So it goes in the generic initializer and fail to decode the list.

Maybe something else is missing?

jackpal commented 3 years ago

If you login and click on your profile it'll load a GenericListContent because it need to displays posts and comments in the same list. With your PR it's not working anymore. It seems like the first initialiser with the where constraints is never called.

So it goes in the generic initializer and fail to decode the list.

Maybe something else is missing?

Are you sure my PR is causing the issue you are seeing? I just forked and built https://github.com/Dimillian/RedditOS on Xcoder 12.3 / MacOS 11.2 beta without my pull request, and when I sign in and click on a profile page, I get this infinite spinner:

Screen Shot 2021-01-02 at 10 19 50 PM

_