# Nested generic trouble

**URL:** <https://forums.swift.org/t/nested-generic-trouble/63152>\
**Category:** Using Swift\
**Tags:** generics\
**Created:** [February 16, 2023, 1:41am UTC](https://forums.swift.org/t/nested-generic-trouble/63152 "2023-02-16T01:41:51Z")\
**Posts on this page:** 1\
**Showing post:** 47

<div class="post-metadata">

**Author:** ![Slava\_Pestov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/slava_pestov/32/30204_2.png) [@Slava\_Pestov](https://forums.swift.org/u/Slava_Pestov)\
**Post date:** [February 20, 2023, 7:33pm UTC](https://forums.swift.org/t/nested-generic-trouble/63152/47 "2023-02-20T19:33:21Z")

</div>

> [@taylorswift](#):
>
> my point this entire time has been that inlining _after_ typechecking doesn’t work very well today, because we don’t have tools in the language today to statically assert that `@inlinable` has been correctly applied to all participants in a call chain that clients who do not care about resilience might call.

Ok, yeah, that’s a fair point, and to be honest this criticism applies to any kind of “best effort” optimization pass, not just generic specialization. Elision of ARC traffic suffers from similar issues due to performance cliffs as well. It seems the solution we’ve settled on for the latter is to encode this in the type system itself using move-only values and types, and perhaps one day we can investigate a similar approach to force specialization of generics or error out when it can’t be done.

However I also think that performance of unspecialized runtime generics is not a totally lost cause either, and there’s work we can do to make it faster. It will never be as fast as specialized code but perhaps if we narrow the gap it will be less of an issue.

---

_[View the full topic](https://forums.swift.org/t/nested-generic-trouble/63152)._
