# KMM generics in Swift: force KMM Any to be Swift Any instead of AnyObject

**URL:** <https://discuss.kotlinlang.org/t/kmm-generics-in-swift-force-kmm-any-to-be-swift-any-instead-of-anyobject/22140>\
**Category:** Multiplatform\
**Created:** [June 16, 2021, 9:19am UTC](https://discuss.kotlinlang.org/t/kmm-generics-in-swift-force-kmm-any-to-be-swift-any-instead-of-anyobject/22140 "2021-06-16T09:19:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kharente-Deuh](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/kharente-deuh/32/8645_2.png) [@Kharente-Deuh](https://discuss.kotlinlang.org/u/Kharente-Deuh)\
**Post date:** [June 16, 2021, 9:19am UTC](https://discuss.kotlinlang.org/t/kmm-generics-in-swift-force-kmm-any-to-be-swift-any-instead-of-anyobject/22140/1 "2021-06-16T09:19:16Z")

</div>

Hi !

I’m currently working on a KMM library that is implemented in Swift.  
So there’s something I don’t really get with generics.

I have my KMM generic class:

```kotlin
class Foo<T> {
 ...
}

```

Then, i can use it without any problem in KMM, for example like that

```kotlin
var bar = Foo<List<SomeClass>>()

```

## The problem:

This is a little different when I use it in swift, cause when I compile my KMM lib as a Swift Framework, my class is now declared this way:

```swift
public class Foo<T> : KotlinBase where T : AnyObject {
 ...
}

```

And here, I cannot use it with Arrays as I do in KMM because a Swift Array is not Any but AnyObject. For example:

```swift
var bar = Foo<[SomeClass]>()

```

and then i got the error:

> ‘Foo’ requires that ‘[AnyObject]’ be a class type

## Question:

Is it possible to force something so that KMM Any is interpreted in Swift as Any and not AnyObject, or is there another solution to this problem ?
