# \#generic-constraint

**URL:** https://forums.swift.org/tag/generic-constraint/724.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [\`var\`-backed parameters passed in with \`@lValue\`, causing inefficient parameter packing](https://forums.swift.org/t/var-backed-parameters-passed-in-with-lvalue-causing-inefficient-parameter-packing/83642)

<div class="topic-metadata">

**Author:** [@Chris\_Williams](https://forums.swift.org/u/Chris_Williams)\
**Replies:** 11\
**Last updated:** [December 10, 2025, 9:47pm UTC](https://forums.swift.org/t/var-backed-parameters-passed-in-with-lvalue-causing-inefficient-parameter-packing/83642 "2025-12-10T21:47:01Z")

</div>

I go into this extensively in Issue #85924, but TL;DR... These two statements type-check differently: func merge\<each A, B\>(\_ a: (repeat each A), \_ b: B) -\> (repeat each A, B) { return (repeat each a, b) } // The …

---

## [How can I make dedicated generic constrained getter?](https://forums.swift.org/t/how-can-i-make-dedicated-generic-constrained-getter/72775)

<div class="topic-metadata">

**Author:** [@NeonTetra](https://forums.swift.org/u/NeonTetra)\
**Replies:** 3\
**Last updated:** [June 27, 2024, 2:59am UTC](https://forums.swift.org/t/how-can-i-make-dedicated-generic-constrained-getter/72775 "2024-06-27T02:59:29Z")

</div>

I can make instance method for dedicated generic constrained method like below // this is just an example extension Array { func getArrayFirst\<T\>() -\> T? where Element == Array\<T\> { first?.first } …

---

## [Some inconsistency in Generic Type Parameter declaration](https://forums.swift.org/t/some-inconsistency-in-generic-type-parameter-declaration/71894)

<div class="topic-metadata">

**Author:** [@RoBo-Inc](https://forums.swift.org/u/RoBo-Inc)\
**Replies:** 11\
**Last updated:** [May 17, 2024, 3:04pm UTC](https://forums.swift.org/t/some-inconsistency-in-generic-type-parameter-declaration/71894 "2024-05-17T15:04:19Z")

</div>

struct Temp\<T: Decodable\>: Decodable { let t: T? } extension KeyedDecodingContainer { func decode\<T\>(\_: Temp\<T\>.Type, forKey key: Key) -\> Temp\<T\> { Temp(t: nil) } } This compiles. But why didn't th…

---

## [Nominal type as a generic constraint](https://forums.swift.org/t/nominal-type-as-a-generic-constraint/59777)

<div class="topic-metadata">

**Author:** [@Dmitriy\_Ignatyev](https://forums.swift.org/u/Dmitriy_Ignatyev)\
**Replies:** 28\
**Last updated:** [March 23, 2023, 5:52am UTC](https://forums.swift.org/t/nominal-type-as-a-generic-constraint/59777 "2023-03-23T05:52:29Z")

</div>

It seems like currently there is no way to use nominal type as generic constraint explicitly. More exactly, such constraints can not be expressed for value types. Though, these constraints can be made for reference types…

---

## [Conditional conformance of type to protocol does not imply conformance to inherited protocol](https://forums.swift.org/t/conditional-conformance-of-type-to-protocol-does-not-imply-conformance-to-inherited-protocol/63076)

<div class="topic-metadata">

**Author:** [@JetForMe](https://forums.swift.org/u/JetForMe)\
**Replies:** 4\
**Last updated:** [February 11, 2023, 4:24pm UTC](https://forums.swift.org/t/conditional-conformance-of-type-to-protocol-does-not-imply-conformance-to-inherited-protocol/63076 "2023-02-11T16:24:28Z")

</div>

I'm getting the error Conditional conformance of type 'API.Page\<T\>' to protocol 'Unmarshaling' does not imply conformance to inherited protocol 'ValueType' when I add the type constraint on the extension, but not if I ha…

---

## [\[Pitch\] - Take associated type inference one step further as compared to Swift 5.7](https://forums.swift.org/t/pitch-take-associated-type-inference-one-step-further-as-compared-to-swift-5-7/61299)

<div class="topic-metadata">

**Author:** [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Replies:** 0\
**Last updated:** [November 8, 2022, 1:02pm UTC](https://forums.swift.org/t/pitch-take-associated-type-inference-one-step-further-as-compared-to-swift-5-7/61299 "2022-11-08T13:02:00Z")

</div>

It would be so lovely if this code compiled: struct SayHi: Procedure { var body: some Procedure\<Void\> { AtomicProcedure { print("Hi 🙋‍♂️") } } } struct AtomicProcedure \<Output\>: Proc…
