# Any chance of implementing opaque type aliases?

**URL:** <https://discuss.kotlinlang.org/t/any-chance-of-implementing-opaque-type-aliases/4145>\
**Category:** Uncategorized\
**Created:** [August 11, 2017, 1:14pm UTC](https://discuss.kotlinlang.org/t/any-chance-of-implementing-opaque-type-aliases/4145 "2017-08-11T13:14:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![harukizaemon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/harukizaemon/32/5862_2.png) [@harukizaemon](https://discuss.kotlinlang.org/u/harukizaemon)\
**Post date:** [August 11, 2017, 1:14pm UTC](https://discuss.kotlinlang.org/t/any-chance-of-implementing-opaque-type-aliases/4145/1 "2017-08-11T13:14:17Z")

</div>

Currently when you create a type alias it’s (AFAICT) purely syntactic sugar for the most part useful in reducing the amount of typing around generics.

What would be nice is a way to create a fully fledged type as an alias for some existing type. For example, I have a custom GUID with some standard factory methods but I want to have an OrderID, ProductID, etc. to al be GUIDs without needing to replicate all the code and without needing to effectively create a composite or other workaround.

Right now I _can_ use type alias but nothing therefore stops me from interchanging the different aliases.

---

<div class="post-metadata">

**Author:** ![vbezhenar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vbezhenar](https://discuss.kotlinlang.org/u/vbezhenar)\
**Post date:** [August 11, 2017, 1:17pm UTC](https://discuss.kotlinlang.org/t/any-chance-of-implementing-opaque-type-aliases/4145/2 "2017-08-11T13:17:20Z")

</div>

You can just use inheritance.

---

<div class="post-metadata">

**Author:** ![harukizaemon](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/harukizaemon/32/5862_2.png) [@harukizaemon](https://discuss.kotlinlang.org/u/harukizaemon)\
**Post date:** [August 11, 2017, 1:24pm UTC](https://discuss.kotlinlang.org/t/any-chance-of-implementing-opaque-type-aliases/4145/3 "2017-08-11T13:24:32Z")

</div>

Hi. Yes that would be the way to go except that it doesn’t work when you have factory methods.

---

<div class="post-metadata">

**Author:** ![alanfo](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@alanfo](https://discuss.kotlinlang.org/u/alanfo)\
**Post date:** [August 11, 2017, 1:50pm UTC](https://discuss.kotlinlang.org/t/any-chance-of-implementing-opaque-type-aliases/4145/4 "2017-08-11T13:50:10Z")

</div>

Having ‘distinct types’ as opposed to ‘typealiases’ is something which is being considered as a future feature using ‘inline classes’ as the vehicle.

Check out [this recent topic](https://discuss.kotlinlang.org/t/implicit-conversions-between-type-aliases/3222) towards the end.
