Loosing type info depending on iteration mode

You have forEach in the first place and for in the second place. The quintessential example:

var values: any Sequence<Int> = [1, 2, 3]
values.forEach { value in
    let x: Int = value // ok, unused variable warning
}
for value in values {
    let x: Int = value // 🛑 Cannot convert value of type 'Any' to specified type 'Int'
}

Why this difference – I don't know.

BTW, indirect is not needed in your example.