First of all, we can look at the example for AnyCollection.
let a1 = AnyCollection([1, 2])
let a2 = AnyCollection(["1", "2"])
let a = [a1, a2] // ❌ Heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional
let b = [AnyCollection([1, 2]), AnyCollection(["1", "2"])] // ✅ Since every element is inferred as AnyCollection<Any> first
Then for "your" AnyMyCollection, it is the same.
I change your AnyMyCollection implementation for simplification.
But it's basically the same. If you still prefer to use your original implementation. You need to conform your collection's element conform to ExpressibleByArrayLiteral
var c1 = AnyMyCollection([1, 2])
var c2 = AnyMyCollection(["1", "2"])
var c = [c1, c2] // ❌ Heterogeneous collection literal could only be inferred to '[Any]'; add explicit type annotation if this is intentional
var d = [AnyMyCollection([1,2]), AnyMyCollection(["1", "2"])] // ✅ Since every element is inferred as AnyMyCollection<Any> first