Initilalization inside extension type inference

I am slightly confused about how swift inference works
In the following code:

extension Array where Element == Int {
    func someMethod() {
        let count = 10
        var arr1: [[Int]] = .init(repeating: [], count: count) // compiles 
        var arr2: [[Int]] = Array(repeating: [], count: count) // doesn't compile

The function Array(repeating:count:) is constraints by the Element of the extension which is Int.
So I can understand the error:
Cannot assign value of type 'Array<Int>' to type '[[Int]]' as the Element of type Int so the compiler anticipate from the initializer [Int] type.
We can relax him by the following (which also makes sense to me ):
var arr2: [[Int]] = Array<[Int]>(repeating: [], count: count)
But I am not sure how he menage to inferrer the the type in the first case? (.init())
I am probably don't understand how the .init() works.
I would also anticipate that it should be similar to the following:
var arr4: [[Int]] = Self<[Int]>.init(repeating: [], count: count)
But I am wrong, can some body please share some light on it.


This is called an implicit member expression. The type is inferred from the expression; it is not equivalent to Self. In your case, the type annotation [[Int]] provides the context for inference. Read more about it here: