# Enhanced Existentials

**URL:** <https://forums.swift.org/t/enhanced-existentials/4859>\
**Category:** Discussion\
**Created:** [January 11, 2017, 1:57am UTC](https://forums.swift.org/t/enhanced-existentials/4859 "2017-01-11T01:57:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Braeden\_Profile](https://avatars.discourse-cdn.com/v4/letter/b/258eb7/32.png) [@Braeden\_Profile](https://forums.swift.org/u/Braeden_Profile)\
**Post date:** [January 11, 2017, 1:57am UTC](https://forums.swift.org/t/enhanced-existentials/4859/1 "2017-01-11T01:57:20Z")

</div>

Looking at that proposal on Austin’s Github, would its complete implementation require/allow for any type that’s known at runtime to be used like a type at compile time? So that these two blocks would both work? It seems like the runtime would be using the same technology, but it’s hard to tell.  
let a : Collection where .Element == Int = // ...  
let b : Collection where .Element == Int = // ...

func someGenericFunc\<C : Collection\>(x: C, y: C) where C.Element == Int {  
&nbsp;&nbsp;&nbsp;&nbsp;// ...  
}

if let openedA = a as? a.Self, let openedB = b as? a.Self {  
&nbsp;&nbsp;&nbsp;&nbsp;// openedA is type a.Self; openedB is type a.Self  
&nbsp;&nbsp;&nbsp;&nbsp;// We now know that openedA and openedB are the same concrete type, which  
&nbsp;&nbsp;&nbsp;&nbsp;// conforms to Collection with Elements that are Ints  
&nbsp;&nbsp;&nbsp;&nbsp;// This is okay  
&nbsp;&nbsp;&nbsp;&nbsp;someGenericFunc(x: openedA, y: openedB)  
}  
let a : Collection where .Element == Int = // ...  
let b : Collection where .Element == Int = // ...

func someGenericFunc\<C : Collection\>(x: C, y: C) where C.Element == Int {  
&nbsp;&nbsp;&nbsp;&nbsp;// ...  
}

let desiredType = type(of: a)  
if let openedA = a as? desiredType, let openedB = b as? desiredType {  
&nbsp;&nbsp;&nbsp;&nbsp;// openedA is type a.Self; openedB is type a.Self  
&nbsp;&nbsp;&nbsp;&nbsp;// We now know that openedA and openedB are the same concrete type, which  
&nbsp;&nbsp;&nbsp;&nbsp;// conforms to Collection with Elements that are Ints  
&nbsp;&nbsp;&nbsp;&nbsp;// This is okay  
&nbsp;&nbsp;&nbsp;&nbsp;someGenericFunc(x: openedA, y: openedB)  
}

assert(type(of: a) === a.Self.self)

---

<div class="post-metadata">

**Author:** ![Nicole\_Jacque](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nicole_jacque/32/245_2.png) [@Nicole\_Jacque](https://forums.swift.org/u/Nicole_Jacque)\
**Post date:** [June 12, 2018, 11:27pm UTC](https://forums.swift.org/t/enhanced-existentials/4859/2 "2018-06-12T23:27:02Z")

</div>

Split this topic on June 12, 2018, 11:27pm UTC

A post was merged into an existing topic: [Enhanced Existentials](https://forums.swift.org/t/enhanced-existentials/4803)

---

<div class="post-metadata">

**Author:** ![Nicole\_Jacque](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nicole_jacque/32/245_2.png) [@Nicole\_Jacque](https://forums.swift.org/u/Nicole_Jacque)\
**Post date:** [June 12, 2018, 11:27pm UTC](https://forums.swift.org/t/enhanced-existentials/4859/3 "2018-06-12T23:27:02Z")

</div>

Closed on June 12, 2018, 11:27pm UTC


