# Multiplatform expect/actual, typealias, and extension functions

**URL:** <https://discuss.kotlinlang.org/t/multiplatform-expect-actual-typealias-and-extension-functions/7582>\
**Category:** Language Design\
**Created:** [April 27, 2018, 10:33pm UTC](https://discuss.kotlinlang.org/t/multiplatform-expect-actual-typealias-and-extension-functions/7582 "2018-04-27T22:33:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kgalligan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kgalligan/32/5014_2.png) [@kgalligan](https://discuss.kotlinlang.org/u/kgalligan)\
**Post date:** [April 27, 2018, 10:33pm UTC](https://discuss.kotlinlang.org/t/multiplatform-expect-actual-typealias-and-extension-functions/7582/1 "2018-04-27T22:33:17Z")

</div>

I’m still verifying that I’m not missing something in the test I’m doing, but here’s what I’m trying to do. I’m using a typealias to implement the ‘actual’ side of an ‘expect’ pair, for jvm and native (ios). The native side has a very similar type signature, but not exact. I was thinking of using extension functions to sort that out, but the ‘actual’ resolution doesn’t see them. I assume that’s because they’re resolved statically.

But, you know, would’ve solved my problem 🙂

Thoughts?

---

<div class="post-metadata">

**Author:** ![pdvrieze](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pdvrieze/32/1882_2.png) [@pdvrieze](https://discuss.kotlinlang.org/u/pdvrieze)\
**Post date:** [April 28, 2018, 8:09pm UTC](https://discuss.kotlinlang.org/t/multiplatform-expect-actual-typealias-and-extension-functions/7582/2 "2018-04-28T20:09:29Z")

</div>

I’ve just done a reasonably large multiplatform-ization. You probably have to go with wrappers. Although if you have an external javascript library you can do some nasty things with externals (especially given how javascript works and isn’t as strict as the JVM). Unfortunately expect/actual is really strict and there are at least two issues:

- poor support for expecting static members of classes (such as `URI.create`)
- no support for function aliasses (like present for types) – inline functions go far, but not the whole way
- If an expected class has a parent interface that is indirectly implemented through a parent in the actual class this will not work (if you specify the interface again it will create a compiler error - there are 2 superclasses; if you don’t specify it again the multiplatform code complains).

---

<div class="post-metadata">

**Author:** ![kgalligan](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kgalligan/32/5014_2.png) [@kgalligan](https://discuss.kotlinlang.org/u/kgalligan)\
**Post date:** [April 29, 2018, 4:44pm UTC](https://discuss.kotlinlang.org/t/multiplatform-expect-actual-typealias-and-extension-functions/7582/3 "2018-04-29T16:44:03Z")

</div>

I’ve refactored and sort of worked around my issues. It’s been an interesting experience. Some things work incredibly well, then you run into an incompatibility and have to unwind a large class structure and rethink.

I’m also doing this to kotlin/native and iOS, so everything is super new. It’s come along, though. Progress!
