# Instantiate associatedtype from outside of protocol

**URL:** <https://forums.swift.org/t/instantiate-associatedtype-from-outside-of-protocol/74311>\
**Category:** Using Swift\
**Tags:** associatedtype, protocol\
**Created:** [September 1, 2024, 3:44pm UTC](https://forums.swift.org/t/instantiate-associatedtype-from-outside-of-protocol/74311 "2024-09-01T15:44:46Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [September 1, 2024, 6:15pm UTC](https://forums.swift.org/t/instantiate-associatedtype-from-outside-of-protocol/74311/6 "2024-09-01T18:15:18Z")

</div>

> [@nickasd](#):
>
> I was expecting `gameType.Options` (which I used in my sample code), or even `game.Options` (as you mentioned, and perhaps you got confused by the similar variable names) to return `any GameOptions`, which is actually what I want (I wasn't expecting a concrete type). Shouldn't the compiler be able to do that? That's basically what you're doing in `_makeOptions()`, right?

Yes, I think looking up an associated type member of a metatype should do that. Or at least the poor diagnostic you observed should be fixed. Do you mind filing an issue?

> [@nickasd](#):
>
> That's not possible in my case, since both `Game` and `Configuration` are part of the framework, which expects the client to pass a `Configuration` object to it.

A good bit of philosophical advice is to design your architecture around what the type system can express, instead of trying to go the other way around.

There will always exist “reasonable” patterns that a static type checker cannot “prove”, pretty much because of the halting problem.

---

_[View the full topic](https://forums.swift.org/t/instantiate-associatedtype-from-outside-of-protocol/74311)._
