Follow

I'm a little embarrassed to admit, but I had been blissfully unaware that View extensions are type erasing.

That means if you have an extension for using your ViewModifier in a more ergonomic way, it'll be erased to AnyView unless you explicitly mark it as @inlinable.

gist.github.com/phillipcaudell

Edit: Perhaps this is just a quirk of Xcode Previews: mastodon.notsobig.co/@phill/11

· Edited · · Ivory for Mac · 3 · 2 · 19

@phill this is extremely surprising. Where is the AnyView even coming from!?

@mattiem yes quite surprising! Presumably AnyView is introduced by the runtime?

I thought it made sense, but now I’m not sure it does. 😅

@phill since the modifier returns ‘some View’ the type information should be preserved.

@jasonhowlin indeed an opaque type should preserve type information, but it appears Xcode Previews for whatever reason discards it. 🤷‍♂️

Sign in to participate in the conversation
The Not So Big Company

The home of The Not So Big Company on Mastodon.